def createDirsHierarchy(self): ''' method to create directories hierarchy as per user. ''' sdirfullpth = '' ssubdirfullpth = '' for i in self.tdirs: sdirfullpth = os.path.join(self.swrkgdir, i) if self.opygenericroutines.createDirIfNotThere(i, self.swrkgdir): sinfo = '%s created.' %(sdirfullpth) prntErrWarnInfo(sinfo, smsgtype = 'info', bresume = True) else: serr = '%s not created.' %(sdirfullpth) self.opygenericroutines.prntLogErrWarnInfo(serr,\ smsgtype = 'err',\ bresume = True) continue for j in self.tsubdirs: ssubdirfullpth = os.path.join(sdirfullpth, j) if self.opygenericroutines.createDirIfNotThere(j,\ sdirfullpth): sinfo = '%s created.' %(ssubdirfullpth) prntErrWarnInfo(sinfo, smsgtype = 'info', bresume = True) else: serr = '%s not created.' %(ssubdirfullpth) self.opygenericroutines.prntLogErrWarnInfo(serr,\ smsgtype = 'err',\ bresume = True) return True
def dumpEMRClusters(self): ''' Method to dump EMR clusters info. ''' try: if self.botoprfl[0] != "default": conn = boto.connect_emr(profile_name=self.botoprfl) else: conn = boto.connect_emr() if conn: print("\n<Start of EMR clusters>\n") print(" Jobflows: %s" % conn.describe_jobflows()) self.opygenericroutines.prntLogErrWarnInfo('', 'info', bresume=True) for c in conn.list_clusters().clusters: ec = " %s" % c self.opygenericroutines.prntLogErrWarnInfo(str(ec), 'info', bresume=True) self.opygenericroutines.prntLogErrWarnInfo('', 'info', bresume=True) print("\n<End of EMR clusters>\n") except Exception, e: serr = ( '%s :: dumpEMRClusters(...) : connect_emr,list_clusters(...).clusters, ' '%s' % (self.sclsnme, str(e))) prntErrWarnInfo(serr, bresume=True)
def dumpEMRClusters(self): ''' Method to dump EMR clusters info. ''' try: if self.botoprfl[0] != "default": conn = boto.connect_emr(profile_name = self.botoprfl) else: conn = boto.connect_emr() if conn: print("\n<Start of EMR clusters>\n") print(" Jobflows: %s" %conn.describe_jobflows()) self.opygenericroutines.prntLogErrWarnInfo('', 'info', bresume = True) for c in conn.list_clusters().clusters: ec = " %s" %c self.opygenericroutines.prntLogErrWarnInfo(str(ec), 'info', bresume = True) self.opygenericroutines.prntLogErrWarnInfo('', 'info', bresume = True) print("\n<End of EMR clusters>\n") except Exception, e: serr = ('%s :: dumpEMRClusters(...) : connect_emr,list_clusters(...).clusters, ' '%s' %(self.sclsnme, str(e))) prntErrWarnInfo(serr, bresume = True)
def mainconsole(opycreateflswthdr): ''' main application driver routine for console mode. ''' if opycreateflswthdr.parseOptsArgs(): if opycreateflswthdr.verifyAndBackup(): opycreateflswthdr.cacheValsFromCnfgFl() for i in opycreateflswthdr.tvldfls: if opycreateflswthdr.createFlwtInfoHdr(i): sflfullpth = os.path.join(opycreateflswthdr.swrkgdir, i) if opycreateflswthdr.bapnd: sinfo = '%s %s'%(sflfullpth, 'appended succesfully.') else: sinfo = '%s %s'%(sflfullpth, 'created succesfully.') prntErrWarnInfo(sinfo, smsgtype = 'info', bresume = True)
# License : GNU GPL v3 http://www.gnu.org/licenses/gpl.html # # Version : 0.0.2 # # Modification history : 1. refactorization of old code with # # pygenericrouties.py by Ankur # # 2. fixed a bug regarding deriving config file # # section name when the app is invoked from other# # locations by Ankur # ############################################################################ try: from pygenericroutines import PyGenericRoutines, prntErrWarnInfo except Exception, e: serr = ('%s, %s' %('from pygenericroutines import PyGenericRoutines', str(e))) prntErrWarnInfo(serr) try: import os.path except Exception, e: serr = '%s, %s' %('import os.path', str(e)) prntErrWarnInfo(serr) try: import sys except Exception, e: serr = '%s, %s' %('import sys', str(e)) prntErrWarnInfo(serr) class PyCreateMySpace:
else: return True try: from pygenericroutines import PyGenericRoutines, prntErrWarnInfo except Exception, e: serr = ('%s, %s' % ('from pygenericroutines import PyGenericRoutines', str(e))) _prntErrWarnInfo(serr) try: import boto, boto.ec2, boto.ec2.elb except Exception, e: serr = '%s, %s' % ('import boto', str(e)) prntErrWarnInfo(serr) try: from boto.vpc import VPCConnection except Exception, e: serr = '%s, %s' % ('from boto.vpc import VPCConnection', str(e)) prntErrWarnInfo(serr) try: import time except Exception, e: serr = '%s, %s' % ('import time', str(e)) prntErrWarnInfo(serr) class DumpAwsInfo():