def main(): options = parser.parse_options("emane80211") start = datetime.datetime.now() print("running emane 80211 example: nodes(%s) time(%s)" % (options.nodes, options.time)) example(options) print("elapsed time: %s" % (datetime.datetime.now() - start))
def main(): options = parser.parse_options("wlan") start = datetime.datetime.now() print "running wlan example: nodes(%s) time(%s)" % (options.nodes, options.time) example(options) print "elapsed time: %s" % (datetime.datetime.now() - start)
def main(): parser, options, arguments = parse_options() if options.file == None: print 'Please provide file path' exit() else: users = get_users(options.file) print users threads = [] for u in users: t = threading.Thread(target=do_check, args=( u, users[u], )) threads.append(t) t.start() time.sleep(1) while True: if not t.is_alive(): print '##############################################' print '##############################################' print '##############################################' print g_out print '##############################################' print '##############################################' print '##############################################' break
def main(): logging.basicConfig(level=logging.INFO) options = parser.parse_options("switch") start = datetime.datetime.now() print("running switch example: nodes(%s) time(%s)" % (options.nodes, options.time)) example(options) print("elapsed time: %s" % (datetime.datetime.now() - start))
def main(): parser, options, arguments = parse_options() if options.file == None: print 'Please provide file path' exit() else: users = get_users(options.file) for u in users: do_check(u, users[u])
def run_command(): command_implementors = ICommand.implementors() if command_implementors and len(sys.argv) > 1: cname = sys.argv[1] # get the command name for command in command_implementors: if command.name_matches(cname): # Remove the command name, since it's not defined # in the parser options sys.argv.remove(cname) command.run(parser.parse_options(use_config = False)) return True return False
def run_command(): command_implementors = ICommand.implementors() if command_implementors and len(sys.argv) > 1: cname = sys.argv[1] # get the command name for command in command_implementors: if command.name_matches(cname): # Remove the command name, since it's not defined # in the parser options sys.argv.remove(cname) command.run(parser.parse_options(use_config=False)) return True return False
def run(self): if run_command(): sys.exit(0) options = parser.parse_options() self.validate_input_params(app_path=options.app_path,\ recv=options.recv, send=options.send,\ wsgi_app=options.wsgi_app) self.options = options # Will be used by the signal handlers try: daemon_options = self._create_daemon_options(options) ctx = daemon.DaemonContext(**daemon_options) with ctx: # Now that we are chrooted (if desired) we should correct # the paths options.app_path = self._normalize_path(options) self._set_loggers(options) self.log.debug( "Using configs values {cfg}".format(cfg=options)) self.log.debug( "Dropping privileges to: uid={uid}, gid={gid}".format( uid=daemon_options['uid'], gid=daemon_options['gid'])) self.log.info("Master process started") self.log.debug("Creating master pid file at {0}".format( self._return_pid_file_path(os.getpid(), self.MASTER))) self._write_pid(os.getpid(), self.MASTER) self._load_plugins(options) if options.nodaemon: self._call_wsgid(options) else: self.workers = [] for worker in range(options.workers): pid = self._create_worker(options) self.workers.append(pid) #Now we can register the master process SIGTERM handler signal.signal(signal.SIGTERM, self._sigterm_handler) self._wait_workers() except Exception, e: import traceback exc = sys.exc_info() self.log.info("".join( traceback.format_exception(exc[0], exc[1], exc[2]))) self._remove_pid(os.getpid(), self.MASTER) sys.exit(1)
def main(): parser, options, arguments = parse_options() if options.file == None: print 'Please provide file path' exit() else: users = get_users(options.file) # print users ps = {} for u in users: ps[u] = Process(target=do_check, args=( u, users[u], )) ps[u].start()
def run_command(): ''' Extract the first command line argument (if it exists) and tries to find a ICommand implementor for it. If found, run it. If not does nothing. ''' command_implementors = ICommand.implementors() if command_implementors and len(sys.argv) > 1: cname = sys.argv[1] # get the command name for command in command_implementors: if command.name_matches(cname): # Remove the command name, since it's not defined # in the parser options sys.argv.remove(cname) command.run(parser.parse_options(use_config=False), command_name=cname) return True return False
def run(self): if run_command(): sys.exit(0) options = parser.parse_options() self.validate_input_params(app_path=options.app_path,\ recv=options.recv, send=options.send,\ wsgi_app=options.wsgi_app) self.options = options # Will be used by the signal handlers try: daemon_options = self._create_daemon_options(options) ctx = daemon.DaemonContext(**daemon_options) with ctx: # Now that we are chrooted (if desired) we should correct # the paths options.app_path = self._normalize_path(options) self._set_loggers(options) self.log.debug("Using configs values {cfg}".format(cfg=options)) self.log.debug("Dropping privileges to: uid={uid}, gid={gid}".format(uid=daemon_options['uid'], gid=daemon_options['gid'])) self.log.info("Master process started") self.log.debug("Creating master pid file at {0}".format(self._return_pid_file_path(os.getpid(), self.MASTER))) self._write_pid(os.getpid(), self.MASTER) self._load_plugins(options) if options.nodaemon: self._call_wsgid(options) else: self.workers = [] for worker in range(options.workers): pid = self._create_worker(options) self.workers.append(pid) #Now we can register the master process SIGTERM handler signal.signal(signal.SIGTERM, self._sigterm_handler) self._wait_workers() except Exception, e: import traceback exc = sys.exc_info() self.log.info("".join(traceback.format_exception(exc[0], exc[1], exc[2]))) self._remove_pid(os.getpid(), self.MASTER) sys.exit(1)
def main(): """ Main function. """ options = parser.parse_options() command = options["known_args"]["command"] if command == "setup": setup.setup_folders(FOLDERS) elif command == "clean": setup.remove_folder(FOLDERS["result"]) elif command == "start": start_time = time.time() functions.start_sort(FOLDERS) print("--- %s seconds ---" % (time.time() - start_time)) elif command == "scan": print("\n### Available folders ###\n") functions.present_folders(FOLDERS) sys.exit()
clients[i].set_format(dest='vm-%s' % args.source) elif args.build: clients[i].set_format(dest=vm.hostname) clients[i].install_packages(args.install) if args.trust: clients[i].set_hostname(subdomain=vm.hostname) clients[i].install_client(vm.hostname) show.untab() if __name__ == '__main__': args = parse_options() try: main(args) except Exception, e: print '***The command above has FAILED***' print 'You can find the logs in ~/<hostname>.log on the VM' print '' print str(e) notify('Scripts on %s failed?!' % args.name) sys.exit(1) notify('Scripts on %s finished :-)' % args.name)