If you need a Lnux Virtual Desktop for developers, then check out http://c9.io
Within 5 minutes, I had registered, logged in, view the sample code, deployed it and an Apache web server and run the code. Super Easy!!
Some of the constraints of other solutions may be;
VMWare View 6 (v1.0 linux desktops)
Building and Managing infrastructure
Short cycle project work
This is a simple piece of code to test if sys.argv matches a file type using a regex to match a specific file type, in this case *.flac (it doesn’t actual check to see if the file is an actual Flac file, just that it is named correctly).
Here is the code with plenty of comments.
Also included (commented out) is the logic to match a date string.
# Author : firstname.lastname@example.org, @shallawell
# A test function to check a if argv contains *.flac
# Filesname: testFLAC.py
# ensure PYTHONPATH is set properly
# Regex for *.flac
pattern = r"([a-zA-Z]?\.flac)"
# Regex for Date
#pattern = r"([a-zA-Z]+) (\d+)"
input = str(sys.argv)
#input = "June 24"
# input = "brian.mp3" # FALSE condition
#input = "brian.mp3.flac" # TRUE condition
if re.search(pattern, input):
match = re.search(pattern, input)
#match = re.search(regex, input)
# This will print [0, 7), since it matches at the beginning and end of the
#print "Match at index %s, %s" % (match.start(), match.end())
# So this will print "June 24"
#print "Full match: %s" % (match.group(0))
print "File ends with FLAC.. runs ok %s" % (match.group(0))
return 0 # pass
# So this will print "June"
#print "Month: %s" % (match.group(1))
# So this will print "24"
#print "Day: %s" % (match.group(2))
# If re.search() does not match, then None is returned
print("Error: Must be a FLAC file .. your file was " + sys.argv)
return 1 # fail
# make the file usable as a script as well as an importable module
if __name__ == "__main__":
import os, fnmatch
# execute function
__version__ = '0.1'
# python testFLAC.py brian.mp3 # fail
# python testFLAC.py brian.mp3.flac # pass
Go to my Git repository to get the source source testFLAC.py source