def main(): 'Get list of files and upload.' log.debug( '%s v%s scalalib:v%s' % (sys.argv[0], __version__, sl.__version__) ) # create script list scripts = [] for filespec in args: results = [] if ('*' in filespec) or ('?' in filespec): results = glob(filespec) else: if os.path.exists(filespec): results = [filespec] for result in results: if os.path.isdir(result): scripts += glob(result + '/*.sca') else: scripts.append(result) if not scripts: log.error('No Script files found.') sys.exit(ERR_FILE) if len(scripts) > 4: # warn on large number of scripts log.warn('About to publish: \n %s' % scripts) print '\n\nHit any key to continue ... Ctrl-C to exit.', msvcrt.getch() try: pubhandle = sl.publish(scripts, opts.targeturl, targetfolder=opts.subfolder, logfilename=opts.logfname, editpassword=opts.editpassword, options=opts.options, autostart=True) log.debug('pubhandle is %s' % pubhandle) if pubhandle: if not verbose: print 'Publishing operation initiated ...' while True: # run at least once time.sleep(pollfreq) status = sl.publish_check(pubhandle) statstr = ('Publishing script %(currentscriptnum)s of %(numberofscripts)s' + ' - %(overallpercentdone)3.3s%% complete, %(currentscriptname)s ') log.info(statstr % status) if status.get('overallpercentdone') == 100 or not verbose: break if status.get('allerrors'): for line in status.get('allerrors').split('\n'): if line and not line.isspace(): log.error(line) elif pubhandle == None: log.critical('No publishing operation started. Cannot continue.') except KeyboardInterrupt: log.warn('Killed by Ctrl-C.') return ERR_KILL except pythoncom.com_error, e: log.error(str(e)) return ERR_UPLD
import sys, os, time sys.path.append('.'); sys.path.append('..') from glob import glob import scalalib as sl sl.get_logger(level='debug') # scripts = [ os.path.abspath(x) for x in glob('*.sca') ] scripts = glob('*.sca') print 'publishing: ', scripts print targeturl = 'http://*****:*****@localhost:8080/ContentManager?SCALA_CUSTOMER' pubhandle = sl.publish(scripts, targeturl, options='d', tologger=True) while False: status = sl.publish_check(pubhandle) print status print statstr = ('Publishing script %(currentscriptnum)s/%(numberofscripts)s' + ' "%(currentscriptname)s" %(overallpercentdone)s%% done.') print statstr % status print if status['overallpercentdone'] == '100': break time.sleep(2)
def main(): 'Get list of files and upload.' log.debug('%s v%s scalalib:v%s' % (sys.argv[0], __version__, sl.__version__)) # create script list scripts = [] for filespec in args: results = [] if ('*' in filespec) or ('?' in filespec): results = glob(filespec) else: if os.path.exists(filespec): results = [filespec] for result in results: if os.path.isdir(result): scripts += glob(result + '/*.sca') else: scripts.append(result) if not scripts: log.error('No Script files found.') sys.exit(ERR_FILE) if len(scripts) > 4: # warn on large number of scripts log.warn('About to publish: \n %s' % scripts) print '\n\nHit any key to continue ... Ctrl-C to exit.', msvcrt.getch() try: pubhandle = sl.publish(scripts, opts.targeturl, targetfolder=opts.subfolder, logfilename=opts.logfname, editpassword=opts.editpassword, options=opts.options, autostart=True) log.debug('pubhandle is %s' % pubhandle) if pubhandle: if not verbose: print 'Publishing operation initiated ...' while True: # run at least once time.sleep(pollfreq) status = sl.publish_check(pubhandle) statstr = ( 'Publishing script %(currentscriptnum)s of %(numberofscripts)s' + ' - %(overallpercentdone)3.3s%% complete, %(currentscriptname)s ' ) log.info(statstr % status) if status.get('overallpercentdone') == 100 or not verbose: break if status.get('allerrors'): for line in status.get('allerrors').split('\n'): if line and not line.isspace(): log.error(line) elif pubhandle == None: log.critical('No publishing operation started. Cannot continue.') except KeyboardInterrupt: log.warn('Killed by Ctrl-C.') return ERR_KILL except pythoncom.com_error, e: log.error(str(e)) return ERR_UPLD
import sys, os, time sys.path.append('.') sys.path.append('..') from glob import glob import scalalib as sl sl.get_logger(level='debug') # scripts = [ os.path.abspath(x) for x in glob('*.sca') ] scripts = glob('*.sca') print 'publishing: ', scripts print targeturl = 'http://*****:*****@localhost:8080/ContentManager?SCALA_CUSTOMER' pubhandle = sl.publish(scripts, targeturl, options='d', tologger=True) while False: status = sl.publish_check(pubhandle) print status print statstr = ('Publishing script %(currentscriptnum)s/%(numberofscripts)s' + ' "%(currentscriptname)s" %(overallpercentdone)s%% done.') print statstr % status print if status['overallpercentdone'] == '100': break time.sleep(2)