<s> import re , os , hashlib , tempfile , subprocess , sys , shlex <EOL> import jasy . core . Console as Console <EOL> def executeCommand ( args , failmsg = None , path = None ) : <EOL> """<STR_LIT>""" <EOL> if type ( args ) == str : <EOL> args = shlex . split ( args ) <EOL> prevpath = os . getcwd ( ) <EOL> if path : <EOL> path = os . path . abspath ( os . path . expanduser ( path ) ) <EOL> os . chdir ( path ) <EOL> Console . debug ( "<STR_LIT>" , "<STR_LIT:U+0020>" . join ( args ) ) <EOL> Console . indent ( ) <EOL> output = tempfile . TemporaryFile ( mode = "<STR_LIT>" ) <EOL> returnValue = subprocess . call ( args , stdout = output , stderr = output , shell = sys . platform == "<STR_LIT:win32>" ) <EOL> output . seek ( <NUM_LIT:0> ) <EOL> result = output . read ( ) . strip ( "<STR_LIT>" ) <EOL> output . close ( ) <EOL> os . chdir ( prevpath ) <EOL> if returnValue != <NUM_LIT:0> : <EOL> raise Exception ( "<STR_LIT>" % ( failmsg , result ) ) <EOL> for line in result . splitlines ( ) : <EOL> Console . debug ( line ) <EOL> Console . outdent ( ) <EOL> return result <EOL> def getKey ( data , key , default = None ) : <EOL> """<STR_LIT>""" <EOL> if key in data : <EOL> return data [ key ] <EOL> else : <EOL> return default <EOL> __REGEXP_DASHES = re . compile ( r"<STR_LIT>" ) <EOL> __REGEXP_HYPHENATE = re . compile ( r"<STR_LIT>" ) <EOL> def __camelizeHelper ( match ) : <EOL> result = match . group ( <NUM_LIT:1> ) <EOL> return result [ <NUM_LIT:0> ] . upper ( ) + result [ <NUM_LIT:1> : ] . lower ( ) <EOL> def __hyphenateHelper ( match ) : <EOL> return "<STR_LIT>" % match . group ( <NUM_LIT:1> ) . lower ( ) <EOL> def camelize ( str ) : <EOL> """<STR_LIT>""" <EOL> return __REGEXP_DASHES . sub ( __camelizeHelper , str ) <EOL> def hyphenate ( str ) : <EOL> """<STR_LIT>""" <EOL> return __REGEXP_HYPHENATE . sub ( __hyphenateHelper , str ) </s>
