def enMain(sysArgsList): args = Arguments.argument(sysArgsList) args.parseArgs() if args.logFile is not None: setConcurrentLogging(logFile=args.logFile) else: setSimpleLogging() logger = logging.getLogger() logger.info('Starting the AdcPatroller...') processList = [] backupProcess = multiprocessing.Process(target=backupAdcConfig, args=(args.adcIp, args.location), kwargs={ 'directorySize': args.directorySize, 'interval': args.backupInterval, 'username': args.username, 'password': args.password, 'mgmtPort': args.mgmtPort, 'telnetPort': args.telnetPort, 'isHttps': args.isHttps }) logger.info('"backupAdcConfig" process has been created.') processList.append(backupProcess) logger.info('Starting all processes ...') for i in processList: i.start() for j in processList: j.join()
def enMain(sysArgsList): myArgs = arguments(sysArgsList) if myArgs.debug: setSimpleLogging(debug=True) else: setSimpleLogging(debug=False) malQuerier = MalQuery(myArgs) malQuerier.start()
def enMain(sysArgsList): args, remaining = argLimit(sysArgsList) if args.debug: setSimpleLogging(debug=True) else: setSimpleLogging(debug=False) logger = logging.getLogger()
def enMain(sysArgsList): args = argument(sysArgsList) if args.debug: setSimpleLogging(debug=True) else: setSimpleLogging(debug=False) # logger = logging.getLogger() standardQuery(args)
def checkSubnet(dstIp): setSimpleLogging() subnetOk = True subnetOkCount = 0 subnetFailCount = 0 command = 'ping ' + str(dstIp) + ' -c 1' while True: logging.info('Starting to ping destination ...') shell_run = subprocess.call(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) if shell_run == 0: logging.info('Destination is reachable.') subnetOkCount += 1 subnetFailCount = 0 else: logging.info('Destination is unreachable.') subnetOkCount = 0 subnetFailCount += 1 if subnetFailCount >= 20: subnetFailCount = 0 if subnetOk == True: unreachableMessage = '[Connectivity Fails!] IP address ' + str( dstIp) + ' for Sunnyvale is unreachable!' myAgent = WechatActive(PredefinedWechat.corpId, PredefinedWechat.secret) myAgent.sendText(PredefinedWechat.agentIdDict['QAinfo'], unreachableMessage, toUserList=['bofei', 'youjunsong']) subnetOk = False if subnetOkCount >= 20: subnetOkCount = 0 if subnetOk == False: reachableMessage = '[Connectivity OK!] IP address ' + str( dstIp) + ' for Sunnyvale is reachable now.' myAgent = WechatActive(PredefinedWechat.corpId, PredefinedWechat.secret) myAgent.sendText(PredefinedWechat.agentIdDict['QAinfo'], reachableMessage, toUserList=['bofei', 'youjunsong']) subnetOk = True print 'Sleep 1 second ...' time.sleep(1)
def mainEn(): setSimpleLogging() scheduleMe('07:10', 'It\'s time to get up and go to defecate now!') scheduleMe('07:40', 'It\'s time to complete defecation and go to to wash now!') scheduleMe('07:55', 'It\'s time to complete your wash and go to cook now!') scheduleMe('09:00', 'It\'s time to go to work now!') scheduleXiaoniuniu('11:35', 'It\'s time to prepare to have lunch with your Dadiao husband, xiaoniuniu~~~^_^~~~') scheduleMe('11:40', 'It\'s time to go home to have lunch with Xiaoniuniu wife now!') scheduleMe('13:40', 'It\'s time to work now!') scheduleXiaoniuniu('22:30', 'It\'s time to wash, Xiaoniuniu~~~^_^~~~') scheduleMe('22:45', 'It\'s time to wash now!') scheduleMe('23:00', 'It\'s time to sleep with your Xiaoniuniu wife now!') scheduleXiaoniuniu('23:05', 'It\'s time to sleep with your Dadiao husband, Xiaoniuniu~~~^_^~~~') sendToUs('Xiaoniuniu assistant has been restarted ... ^_^~~~') taskString = '' for i in taskList: taskString = taskString + i + '\n' sendToUs(taskString) while True: schedule.run_pending() time.sleep(60) # wait one minute
from NxSanfran.NxEtc.NxPublic.NxPredefault.Default import * from NxSanfran.NxTools import RemovePyc from NxSanfran.NxUsr.NxLib import NxFiles from NxSanfran.NxUsr.NxLib.NxLogging import setSimpleLogging import logging exceptList = [ 'README.rst', '__init__.py', 'NxPrjcts' ] setSimpleLogging() def clearFiles(path, additionalExceptList=[]): logging.info('Clearing the files in '+str(path)+' ...') filesInPath = NxFiles.listDir(path) for i in filesInPath: if i not in exceptList and i not in additionalExceptList: NxFiles.removeForce(path+'/'+str(i)) logging.warning(path+'/'+str(i)+' has been removed!') logging.info('Clean up the ".pyc" file ...')