def setup_cloud(context, scenario): creds = [ context.options.cf.apiurl, context.options.cf.username, context.options.cf.password, context.options.cf.org ] if [cred for cred in creds if cred]: if None in creds: raise Exception( 'if setting CloudFoundry credentials, all of cf_apiurl, cf_username, cf_password, cf_org must be set' ) context.env['CF_HOME'] = context.sandbox_dir command.Command( context, 'cf login -a {} -u {} -p {} -o {} -s development'.format( context.options.cf.apiurl, context.options.cf.username, context.options.cf.password, context.options.cf.org)).run() else: context.log.info( 'CloudFoundry credentials not provided, assuming already logged in' ) context.cf_space = context.options.cf.space if not context.cf_space: context.cf_space = uuid.uuid4() command.Command(context, 'cf create-space {}'.format(context.cf_space)).run() cmd = command.Command(context, 'cf target -s {}'.format(context.cf_space)) cmd.run() def cleanup(): cmd = command.Command(context, 'cf delete-space -f {}'.format(context.cf_space)) cmd.run() context.cleanups.append(cleanup)
def init(self): x = 10 y = 10 #Test mode for mode in TestMode.modes: radioBtn = GUI.Radiobutton(self.widget, text=mode['name'], font=self.font, value=mode['value'], bg=self.bg) if DS.DataSet.getData('current_mode') == mode['value']: radioBtn.select() radioBtn.bind( '<Button-1>', CMD.Command(self.clickHandle, value=mode['value'], type='mode')) radioBtn.place(x=x, y=y) x += len(mode['name']) * 18 # buttons = ({ 'name': u'开始', 'value': 0x1 }, { 'name': u'停止', 'value': 0x2 }) x += 20 for btn in buttons: btnInst = GUI.Button(self.widget, text=btn['name'], font=u'微软雅黑 -18 bold', bd=3, width=len(btn['name']) << 2, height=1) btnInst.config(bg=self.bg) self.addChild(btnInst) btnInst.bind( '<Button-1>', CMD.Command(self.clickHandle, type='button', value=btn['value'])) btnInst.place(x=x, y=y) x += len(btn['name']) * 55 + 15 # height = self.root.height - 140 self.progressFrame = GUI.LabelFrame(self.widget, text=u'【当前进度】') self.progressFrame.config(width=400, height=height, bg=self.bg) self.progressFrame.place(x=10, y=60) self.progressTxt = GUI.Message(self.progressFrame, width=400, bg=self.bg) self.progressTxt.place(x=0, y=0) self.testDriver = TD.TestDriver(self, rows=3, cols=2, x=420, y=10, width=self.width - 420, height=self.height - 10) return self
def HostLibs(host): libs = {} if TripleIsWindows(host): if pynacl.platform.IsWindows(): ar = 'ar' else: ar = 'i686-w64-mingw32-ar' libs.update({ 'libdl': { 'type': 'build', 'inputs': { 'src': os.path.join(NACL_DIR, '..', 'third_party', 'dlfcn-win32') }, 'commands': [ command.CopyTree('%(src)s', '.'), command.Command([ 'i686-w64-mingw32-gcc', '-o', 'dlfcn.o', '-c', 'dlfcn.c', '-Wall', '-O3', '-fomit-frame-pointer' ]), command.Command([ar, 'cru', 'libdl.a', 'dlfcn.o']), command.Copy('libdl.a', os.path.join('%(output)s', 'libdl.a')), command.Copy('dlfcn.h', os.path.join('%(output)s', 'dlfcn.h')), ], }, }) return libs
def update(self, ServerState): # update all before new round self.size_m = len(ServerState.d['units_myself']) self.size_e = len(ServerState.d['units_enemy']) if len(self.units) == 0: for uid, ut in ServerState.d['units_myself'].iteritems(): u = unit_n(ut, 0) self.units[u.uid] = u self.units_id.append(u.uid) for uid, ut in ServerState.d['units_enemy'].iteritems(): u = unit_n(ut, 1) self.units[u.uid] = u self.units_e_id.append(u.uid) else: self.units_id = self.upset_unit(ServerState) self.units_e_id = [] for uid, ut in ServerState.d['units_enemy'].iteritems(): self.units_e_id.append(uid) self.units_dead_id = [] for uid, ut in self.units.iteritems(): if ut.enemy == 0: if uid in ServerState.d['units_myself']: # alive self.units[uid].order = ServerState.d['units_myself'][uid].orders[0] self.units[uid].x = ServerState.d['units_myself'][uid].x self.units[uid].y = ServerState.d['units_myself'][uid].y self.units[uid].hp = ServerState.d['units_myself'][uid].health self.units[uid].shield = ServerState.d['units_myself'][uid].shield self.units[uid].cd = ServerState.d['units_myself'][uid].groundCD self.units[uid].next_cmd = command.Command() self.units[uid].next_cmd.target_pos_x = self.units[uid].x self.units[uid].next_cmd.target_pos_y = self.units[uid].y else: self.units[uid].dead() self.units_dead_id.append(uid) else: if uid in ServerState.d['units_enemy']: # alive self.units[uid].order = ServerState.d['units_enemy'][uid].orders[0] self.units[uid].x = ServerState.d['units_enemy'][uid].x self.units[uid].y = ServerState.d['units_enemy'][uid].y self.units[uid].hp = ServerState.d['units_enemy'][uid].health self.units[uid].shield = ServerState.d['units_enemy'][uid].shield self.units[uid].cd = ServerState.d['units_enemy'][uid].groundCD self.units[uid].next_cmd = command.Command() self.units[uid].next_cmd.target_pos_x = self.units[uid].x self.units[uid].next_cmd.target_pos_y = self.units[uid].y else: self.units[uid].dead() self.units_dead_id.append(uid) if self.units[uid].death == 0: #self.units[uid].pos = unit_n.set_pos(self.units[uid].x, self.units[uid].y) self.units[uid].set_cur_cmd() # order to command if (self.units[uid].cur_cmd.act_type == 1): self.units[uid].cur_cmd.target_pos_x = self.units[self.units[uid].cur_cmd.targetID].x self.units[uid].cur_cmd.target_pos_y = self.units[self.units[uid].cur_cmd.targetID].y
def dead(self): self.death = 1 #self.pos = -1 self.hp = 0 self.shield = 0 self.cd = -1 self.order = frame.Order() self.cur_cmd = command.Command() self.next_cmd = command.Command()
def UnsandboxedRuntime(arch, is_canonical): assert arch in ('arm-linux', 'x86-32-linux', 'x86-32-mac', 'x86-64-linux') compiler = { 'arm-linux': 'arm-linux-gnueabihf-gcc', 'x86-32-linux': 'gcc', 'x86-32-mac': 'gcc', # x86-64 can't use gcc because the gcc available in the bots does not # support x32. clang is good enough for the task, and it is available in # the bots. 'x86-64-linux': '%(abs_target_lib_compiler)s/bin/clang', }[arch] arch_cflags = { 'arm-linux': ['-mcpu=cortex-a9', '-D__arm_nonsfi_linux__'], 'x86-32-linux': ['-m32'], 'x86-32-mac': ['-m32'], 'x86-64-linux': ['-mx32'], }[arch] libs = { GSDJoin('unsandboxed_runtime', arch): { 'type': TargetLibBuildType(is_canonical), 'output_subdir': os.path.join('translator', arch, 'lib'), 'dependencies': [ 'subzero_src', 'target_lib_compiler'], # This lib #includes # arbitrary stuff from native_client/src/{include,untrusted,trusted} 'inputs': { 'support': os.path.join(NACL_DIR, 'src', 'nonsfi', 'irt'), 'untrusted': os.path.join( NACL_DIR, 'src', 'untrusted', 'irt'), 'include': os.path.join(NACL_DIR, 'src'), }, 'commands': [ # The NaCl headers insist on having a platform macro such as # NACL_LINUX defined, but src/nonsfi/irt_interfaces.c does not # itself use any of these macros, so defining NACL_LINUX here # even on non-Linux systems is OK. # TODO(dschuff): this include path breaks the input encapsulation # for build rules. command.Command([compiler] + arch_cflags + ['-O2', '-Wall', '-Werror', '-I%(top_srcdir)s/..', '-DNACL_LINUX=1', '-DDEFINE_MAIN', '-c', command.path.join('%(support)s', 'irt_interfaces.c'), '-o', command.path.join('%(output)s', 'unsandboxed_irt.o')]), command.Command([compiler] + arch_cflags + ['-O2', '-Wall', '-Werror', '-I%(top_srcdir)s/..', '-c', command.path.join('%(support)s', 'irt_random.c'), '-o', command.path.join('%(output)s', 'irt_random.o')]), command.Command([compiler] + arch_cflags + ['-O2', '-Wall', '-Werror', '-I%(top_srcdir)s/..', '-c', command.path.join('%(untrusted)s', 'irt_query_list.c'), '-o', command.path.join('%(output)s', 'irt_query_list.o')]), ] + SubzeroRuntimeCommands(arch, '%(output)s'), }, } return libs
def SandboxedTranslators(arches): le32_packages = [ 'newlib_le32', 'libcxx_le32', 'libs_support_le32', 'core_sdk_libs_le32', 'metadata', 'compiler_rt_bc_le32' ] arch_deps = [GSDJoin('libs_support_translator', arch) for arch in arches] def TranslatorLibDir(arch): return os.path.join('%(output)s', 'translator', pynacl.platform.GetArch3264(arch), 'lib') translators = { # The translator build requires the PNaCl compiler, the le32 target libs # and core SDK libs, and the native translator libs for the target arches 'translator_compiler': { 'type': 'work', 'dependencies': ['target_lib_compiler'] + le32_packages + arch_deps, 'commands': [ # Copy the le32 bitcode libs command.CopyRecursive('%(' + p + ')s', '%(output)s') for p in ['target_lib_compiler'] + le32_packages ] + [ # Also copy the le32 libcxx headers to the root of the # translator_compiler package. # TODO: This works around a bug in le32-nacl-clang's include # path logic (it should use le32-nacl/include but instead it # uses /include, which probably should just be a host path. command.CopyRecursive('%(libcxx_le32)s/le32-nacl/include', '%(output)s/include') ] + [ # Copy the native translator libs command.CopyRecursive( '%(' + GSDJoin('libs_support_translator', arch) + ')s', TranslatorLibDir(arch)) for arch in arches ], }, 'sandboxed_translators': { 'type': 'build', 'dependencies': ['translator_compiler'], 'inputs': { 'build': os.path.join(NACL_DIR, 'pnacl', 'build.sh'), '_': os.path.join(NACL_DIR, 'pnacl', 'scripts', 'common-tools.sh'), }, 'commands': [ command.Command(['%(abs_build)s', 'translator-all']), command.Command(['%(abs_build)s', 'translator-prune']), ], }, } return translators
def D2NLibsSupportCommands(bias_arch, clang_libdir): def TL(lib): return GSDJoin(lib, pynacl.platform.GetArch3264(bias_arch)) def TranslatorFile(lib, filename): return os.path.join('%(' + TL(lib) + ')s', filename) commands = [ # Build compiler_rt which is now also used for the PNaCl # translator. command.Command(MakeCommand() + [ '-C', '%(abs_compiler_rt_src)s', 'ProjObjRoot=%(cwd)s', 'VERBOSE=1', 'AR=' + PnaclTool('ar', arch=bias_arch), 'RANLIB=' + PnaclTool('ranlib', arch=bias_arch), 'CC=' + PnaclTool('clang', arch=bias_arch), 'clang_nacl', 'EXTRA_CFLAGS=' + NewlibIsystemCflags(bias_arch) ]), command.Mkdir(clang_libdir, parents=True), command.Copy( os.path.join( 'clang_nacl', 'full-' + bias_arch.replace('i686', 'i386').replace('mipsel', 'mips32'), 'libcompiler_rt.a'), os.path.join('%(output)s', clang_libdir, 'libgcc.a')), command.Copy(TranslatorFile('libgcc_eh', 'libgcc_eh.a'), os.path.join('%(output)s', clang_libdir, 'libgcc_eh.a')), BuildTargetObjectCmd('clang_direct/crtbegin.c', 'crtbeginT.o', bias_arch, output_dir=clang_libdir), BuildTargetObjectCmd('crtend.c', 'crtend.o', bias_arch, output_dir=clang_libdir), ] if bias_arch == "mipsel": commands.extend([ BuildTargetObjectCmd('bitcode/pnaclmm.c', 'pnaclmm.o', bias_arch), BuildTargetObjectCmd('clang_direct/nacl-tp-offset.c', 'nacl_tp_offset.o', bias_arch, extra_flags=['-I%(top_srcdir)s/..']), command.Command([ PnaclTool('ar'), 'rc', command.path.join(clang_libdir, 'libpnacl_legacy.a'), command.path.join('pnaclmm.o'), command.path.join('nacl_tp_offset.o') ]) ]) return commands
def __init__(self): self.__commands_list = [ cmd.Command(b'terminal length 0\n'), cmd.VersionCommand(b'show version | include flash:/\n'), cmd.SerialNumberCommand(b'show inventory | include SN\n'), ] with open('commands.txt') as commands: for command in commands: command = command.rstrip('\n') self.__commands_list.append( cmd.Command(command.encode('ascii') + b'\n')) self.__commands_list.append(cmd.Command(b'exit\n'))
def scan(self): #commands commands = [] #dbg msg utils.logMessage(utils.MODE_INFO, 'running scan') #init results dictionary results = self.initResults(LAUNCHD_CONF_NAME, LAUNCHD_CONF_DESCRIPTION) #get all commands in launchd.conf # ->note, commands in functions will be ignored... commands = utils.parseBashFile(LAUNCHD_CONF_FILE) #iterate over all commands # ->instantiate command obj and save into results for extractedCommand in commands: #TODO: could prolly do some more advanced processing (e.g. look for bsexec, etc) #instantiate and save results['items'].append(command.Command(extractedCommand)) return results
def BuildTargetNativeCmd(sourcefile, output, arch, extra_flags=[], source_dir='%(src)s', output_dir='%(cwd)s'): return command.Command([ PnaclTool('clang', msys=False), '--pnacl-allow-native', '--pnacl-allow-translate', '-Wall', '-Werror', '-arch', arch, '--pnacl-bias=' + arch, '-O3', # TODO(dschuff): this include breaks the input encapsulation for build # rules. '-I%(top_srcdir)s/..', '-isystem', '%(newlib_portable)s/include', '-c' ] + extra_flags + [ command.path.join(source_dir, sourcefile), '-o', command.path.join(output_dir, output) ])
def main(payload, port): """Sends a custom command.""" # Setup Serial serial.configure(port=port, speed=1000000) serial.run() # Build Command cmd = command.Command(payload) # Send Command cmd.send(serial) # Check command for error if error.check(cmd.status): click.echo("Command Error:" + str(cmd.status)) sys.exit() # Wait for response resp = command.Response(serial) # Parse response resp.parse() # Check response status code if error.check(resp.status): click.echo("Response Error:" + str(resp.status)) sys.exit() # Print Response resp.print()
def generate_run_command(job, results_dir, scarab_params): scarab_args = job.scarab_args + scarab_params.scarab_args + \ " --num_cores {num_cores} --output_dir {output_dir}".format(num_cores=job.num_cores, output_dir=results_dir) params_file = scarab_params.params_file scarab_launch_cmd = scarab_params.python_bin + " " + \ scarab_params.scarab_launch + \ " --scarab " + scarab_params.scarab + \ " --frontend_pin_tool " + scarab_params.frontend_pin_tool + \ " --pintool_args=\"" + scarab_params.pintool_args + " " + job.pintool_args + "\"" \ " --scarab_args=\"" + scarab_params.scarab_args + " " + scarab_args + "\"" \ " --params " + params_file + \ " --scarab_stdout " + results_dir + "/" + scarab_params.scarab_stdout + \ " --scarab_stderr " + results_dir + "/" + scarab_params.scarab_stderr + \ " --pin_stdout " + results_dir + "/" + scarab_params.pin_stdout + \ " --pin_stderr " + results_dir + "/" + scarab_params.pin_stderr + \ get_program_or_checkpoint_options(job) launch_out = results_dir + "/" + scarab_params.scarab_launch_stdout launch_err = results_dir + "/" + scarab_params.scarab_launch_stderr cmd = command.Command(scarab_launch_cmd, name=job.name, run_dir=results_dir, results_dir=results_dir, stdout=launch_out, stderr=launch_err) cmd.walltime = scarab_params.walltime cmd.memory_per_core = scarab_params.memory_per_core cmd.cores = scarab_params.cores cmd.snapshot_log = scarab_params.snapshot_log return cmd
def PopulateDeps(dep_dirs): commands = [command.RemoveDirectory('all_deps'), command.Mkdir('all_deps')] commands += [ command.Command('cp -r "%s/"* all_deps' % dirname, shell=True) for dirname in dep_dirs ] return commands
def setUp(self): # Players: self.p0 = state.State() self.p1 = state.State() self.p0.opponent = self.p1 self.p1.opponent = self.p0 self.cmd = command.Command(self.p0)
def do(): rpc_connection = config.get_rpc() txid = request.args.get('txid') sample_transaction = transactions.get_tx(txid, tx_cache, rpc_connection) parsed_tx = transactions.parse_transaction(sample_transaction, tx_cache, rpc_connection) temp_file = open("/tmp/1", "w") script_input = "" script_input += "#input\n" for input in range(0, len(parsed_tx[0])): if input % 2 == 0: script_input += parsed_tx[0][input] + " " + str(parsed_tx[0][input+1]) + "\n" script_input += "\n#output\n" for output in parsed_tx[1:]: script_input += output[0] + " " + str(output[1]) + "\n" temp_file.write(script_input) temp_file.write("\n") temp_file.close() tx_command = command.Command("/usr/bin/java -cp bin graphAnalysis.TransactionAnalysis /tmp/1".split()) tx_command.run(timeout = 5) output = tx_command.stdout if len(output.strip()) is 0: output = "Script timed out on your transaction! Congrats, you are probably at least a bit secure :)" return render_template("done.html", tx_out = output, tx_rep = script_input)
def __init__(self, uc, flag): # flag myself or enemy self.uid = uc.id self.x = uc.x self.y = uc.y #self.pos = self.set_pos(self.x, self.y) self.enemy = flag self.type = uc.type self.hp = uc.health self.shield = uc.shield self.cd = uc.groundCD self.cur_cmd = command.Command() self.next_cmd = command.Command() self.order = uc.orders[0] self.set_cur_cmd() self.feature = [] self.death = 0
def start(self): ''' Start a jboss instance ''' logging = logger.Logger().logger address = self.options.jboss_address instance = self.options.jboss_instance jboss_run_path = self.options.jboss_home + "/bin/run.sh" status = self.status() if len(self.search_by_address(address=address, status=status)) != 0: return (-1, "Another instances listening on this address, ") if len(self.search_by_instance(instance=instance, status=status)) != 0: return (-1, "This instances is just instanced") launcher = "sh " + str( jboss_run_path) + " -c " + instance + " -b " + address + " &" logging.info(launcher) comm = command.Command() comm.run(launcher) return "OK, instance " + instance + " started on address " + address
def main(): cmd = command.Command(sys.argv[1:]) # cmd.debug_enable() cmd.bind("help", cmd.help, "显示命令帮助") cmd.bind("show-singer <singername>", show_singer, "显示某歌手的统计信息") cmd.bind("show-album <singername> <albumname>", show_album, "显示某歌手某专辑的信息") cmd.bind("list-album <singername> [-v|--verbose]", list_album, "显示某歌手的所有专辑(-v显示更多信息)") cmd.bind("list-song -s <singername> -a <albumname> [-v|--verbose]", list_song, "显示某歌手(或某专辑)的所有歌曲(-v显示更多信息)") cmd.bind("search-song <singername> <songname>", search_song, "按歌手和歌曲名搜索歌曲") cmd.bind("search <keyword> ", search_keyword, "按关键字搜索") cmd.bind("download-link <singername> <songname>", download_link, "按歌手和歌名搜索歌曲,并列出这首歌的下载地址") cmd.bind("show-lyric <singername> <songname> -t <lyric_type>", show_lyric, "按歌手和歌名搜索歌曲,并输出这首歌的歌词") # 播放列表 cmd.bind("playlist show", playlist_show, "列出播放列表里的歌曲") cmd.bind("playlist add <song_no>", playlist_add, "添加歌曲到播放列表") cmd.bind("playlist clear", playlist_clear, "清空播放列表里的歌曲") cmd.bind("playlist set-quality", playlist_set_qualities_order, "设置音质优先级列表") cmd.bind("playlist save-link <filepath>", playlist_save_download_link, "把播放列表歌曲的下载链接保存到指定文件") cmd.bind("playlist download <dir> [--krc] [--lrc] [--onlylyric]", playlist_download, "把播放列表歌曲下载到指定位置") cmd.run()
def main(): # 主机名 ip 序列号 ipall_dict = {} for x in xrange(1, 2): ip_msg = [] ip = "10.10.10.%d" % x # 获取连接对象 agent = ssh_agent.SSHAgent().ssh(ip) # 执行相关的命令, 定义好的命令 cmd = command.Command(agent) results = cmd.load() print "#######################" print results print "#######################" # 执行解析, 注意每个命令的结果不一样,需要不同的解析方式 ps = mparser.Parser(cmd) res_parse = ps.parse() print "#######################" print res_parse print "#######################" # 存储结果,可以是文本,数据库,其他 st = store.Store(ps) st.store()
def __init__(self, api_token: str = "", group_id: int = 0, sys_path: str = "", base_name: str = "Default", server_name: str = "Empty", time_delta_hour: int = 3): # инициализируем часовой пояс self.time_delta_hour = time_delta_hour self.time_delta = datetime.timedelta(hours=self.time_delta_hour, minutes=0) # Даем серверу имя self.server_name = server_name # запоминаем id группы self.group_id = group_id # создаем папку сервера self.folder_path = sys_path + "\\" + server_name if not os.path.exists(self.folder_path): os.makedirs(self.folder_path) # -------------------------------------------------------------------------------------------------------------- # Для Long Poll self.vk = vk_api.VkApi(token=api_token) # Для использования Long Poll API self.long_poll = VkBotLongPoll(self.vk, group_id) # Для вызова методов vk_api self.vk_api = self.vk.get_api() # -------------------------------------------------------------------------------------------------------------- # инициализация базы данных self.base_name = base_name self.database = database.DataBase(self.folder_path, self.base_name) # -------------------------------------------------------------------------------------------------------------- # инициализация класса, обрабатывающего команды self.command_hm = command_headman.Command_headman(self.folder_path, self.time_delta_hour, self.base_name) self.command = command.Command(self.folder_path, self.time_delta_hour, self.base_name) self.log = logining.Logining(self.folder_path, self.time_delta_hour)
def scan(self): #commands commands = [] #dbg msg utils.logMessage(utils.MODE_INFO, 'running scan') #init results dictionary results = self.initResults(RC_SCRIPT_NAME, RC_SCRIPT_DESCRIPTION) #scan/parse all rc files for rcScript in RC_SCRIPTS: #get all commands in script file # ->note, commands in functions will be ignored... # of course, if the function is invoked, this invocation will be displayed commands = utils.parseBashFile(os.path.join('/etc', rcScript)) #iterate over all commands # ->instantiate command obj and save into results for extractedCommand in commands: #instantiate and save results['items'].append( command.Command(extractedCommand, rcScript)) return results
def parseCommand(password, text): commands = [] commans_raw = text.split(';') if (len(commans_raw) > 1): if (commans_raw[0] == password): for x in range(1, len(commans_raw)): c = commans_raw[x] if (c.find('=') != -1): cp = c.split('=') if (len(cp) > 1): commands.append(command.Command(cp[0], cp[1])) else: commands.append(command.Command(c, '')) else: commands.append(command.Command('WRONG_PASSWORD', '')) return commands
def new_circuit(self, circ_event): """ Invoke a new probing module when a new circuit becomes ready. """ self.stats.update_circs(circ_event) self.check_finished() if circ_event.status not in [CircStatus.BUILT]: return last_hop = circ_event.path[-1] exit_fpr = last_hop[0] logger.debug("Circuit for exit relay \"%s\" is built. " "Now invoking probing module." % exit_fpr) run_cmd_over_tor = command.Command(self.queue, circ_event.id, socket.socket) exit_desc = get_relay_desc(self.controller, exit_fpr) if exit_desc is None: self.controller.close_circuit(circ_event.id) return module = module_closure( self.queue, self.module.probe, circ_event.id, exit_desc, command.run_python_over_tor(self.queue, circ_event.id, self.socks_port), run_cmd_over_tor) proc = multiprocessing.Process(target=module) proc.daemon = True proc.start()
def SDKLibs(arch, is_canonical, extra_flags=[]): scons_flags = ['--verbose', 'MODE=nacl', '-j%(cores)s', 'naclsdk_validate=0', 'pnacl_newlib_dir=%(abs_sdk_compiler)s', 'DESTINATION_ROOT=%(work_dir)s'] scons_flags.extend(extra_flags) if arch == 'le32': scons_flags.extend(['bitcode=1', 'platform=x86-32']) elif not IsBCArch(arch): scons_flags.extend(['nacl_clang=1', 'platform=' + pynacl.platform.GetArch3264(arch)]) else: raise ValueError('Should not be building SDK libs for', arch) libs = { GSDJoin('core_sdk_libs', arch): { 'type': TargetLibBuildType(is_canonical), 'dependencies': ['sdk_compiler', 'target_lib_compiler'], 'inputs': { 'src_untrusted': os.path.join(NACL_DIR, 'src', 'untrusted'), 'src_include': os.path.join(NACL_DIR, 'src', 'include'), 'scons.py': os.path.join(NACL_DIR, 'scons.py'), 'site_scons': os.path.join(NACL_DIR, 'site_scons'), }, 'commands': [ command.Command( [sys.executable, '%(scons.py)s', 'includedir=' +os.path.join('%(output)s', TripleFromArch(MultilibArch(arch)), 'include'), 'libdir=' + os.path.join('%(output)s', MultilibLibDir(arch)), 'install'] + scons_flags, cwd=NACL_DIR), ], } } return libs
def ConfigureTargetPrep(arch): script_file = 'strip_for_target' config_target = arch + '-nacl' script_contents = """\ #!/bin/sh mode=--strip-all for arg; do case "$arg" in -*) ;; *) type=`file --brief --mime-type "$arg"` case "$type" in application/x-executable|application/x-sharedlib) ;; application/x-archive|application/x-object) mode=--strip-debug ;; *) exit 0 ;; esac ;; esac done exec %s-strip $mode --remove-section=.comment "$@" """ % config_target return [ command.WriteData(script_contents, script_file), command.Command(['chmod', '+x', script_file]), ]
def new_circuit(self, circ_event): """ Invoke a new probing module when a new circuit becomes ready. """ self.stats.update_circs(circ_event) self.check_finished() if circ_event.status not in [CircStatus.BUILT]: return last_hop = circ_event.path[-1] exit_fpr = last_hop[0] logger.debug("Circuit for exit relay \"%s\" is built. " "Now invoking probing module." % exit_fpr) # Prepare the execution environment. In particular, a Command() object # to execute external tools and a decorator for the probing module we # are about to run. cmd = command.Command("doc/torsocks.conf", self.queue, circ_event.id, self.origsock) func = decorator(self.queue, self.origsock, self.probing_module, circ_event.id, exit_fpr, cmd) # Monkey-patch the socket API to redirect network traffic originating # from our Python process to Tor's SOCKS port. socket.socket = mysocks.socksocket mysocks.setqueue(self.queue, circ_event.id) proc = multiprocessing.Process(target=func) proc.daemon = True proc.start()
def main(): """Execute the command""" parser = argparse.ArgumentParser(description='Drive quadcopter from a command line') parser.add_argument('-t', '--ttyname', help='Serial tty to transmitter.', required=False, default='/dev/ttyACM0') args = parser.parse_args() c = command.Command(args.ttyname) while True: text = input('> ') if text == 'a': c.arm() print('Armed') elif text == 'b': print('Binding...') c.bind() print(' done') elif text == 'd': c.disarm() print('Disarm') elif text == '': continue elif text == 'q': break elif text == 'h': help(); elif text == '?': help(); else: execute(c, text)
def AddCommand(self): parent.commands.append( command.Command(self.vm.RecordedKeychain, self.vm.ProgramPath, [ x.replace(self.space_escaping, ' ') for x in self.vm.Arguments.replace('\ ', self.space_escaping).split(' ') ])) parent.reader.dump_commands(parent.commands) self.update_list()
def SaveCommand(self): parent.commands[self.vm.SelectedIndex] = command.Command( self.vm.RecordedKeychain, self.vm.ProgramPath, [ x.replace(self.space_escaping, ' ') for x in self.vm.Arguments.replace('\ ', self.space_escaping).split(' ') ]) parent.reader.dump_commands(parent.commands) self.update_list()