Exemple #1
0
 def run_command(self, cmd):
     """Split multicommand and each one separated"""
     arg_list = ''
     if self.conf.arguments_pipe in cmd:
         cmd, arg_list = cmd.split(self.conf.arguments_pipe, 1)
     # split command by the conf.cmd_separator
     cmd_list = cmd.split(self.conf.cmd_separator)
     # split the cmd_list into cmd and arg_list
     for c in cmd_list:
         c = c.strip()
         c = " ".join([c, arg_list])
         if not self.run_single_command(c):
             break
 def execute_FASTQC(self, opts):
     """Execute FASTQC for BAMs in case folder."""
     
     print """#--------------------FASTQC QUALITY CONTROL--------------------#"""
     
     # Gather BAM list from current working directory
     bam_list = []
     for bam in os.listdir(os.getcwd()):
         if bam.endswith(".bam"):
             bam_list.append(bam)
     
     # make FASTQC directory if it doesn't exist
     try:
         os.makedirs("./FASTQC")
     except OSError as e:
         if e.errno != errno.EEXIST:
             raise
     
     
     log = open('./FASTQC/%s.fastqc.log' % opts.base_output, 'a+')
     
     # Run FASTQC command on all bams in directory using 8 threads    
     cmd = "fastqc -f bam -t 8 -o FASTQC %s" % " ".join(bam_list)
     p = subprocess.Popen(cmd.split(" "), stdout = log, stderr = log)
     p.communicate()
     
     # Close log
     log.close()
     
     # Delete .zip file created by FASTQC
     # We only need the uncompressed output directory for review
     fastqc_dir = os.path.join(os.getcwd(), "FASTQC")
     for f in os.listdir(fastqc_dir):
         if f.endswith(".zip"):
             os.remove(os.path.join(fastqc_dir, f))
Exemple #3
0
	def do_relay(self,cmd):
		"""relay PEER [LOCAL] REMOTE: relay connections to localhost:LOCAL to port REMOTE on PEER. if LOCAL is 0 or ommitted, a free port is used."""
		if self.client.client is None:
			self.stdout.write("Error: Not connected!\n")
			return
		if not self.ingroup:
			self.stdout.write("Error: Not in a group!\n")
			return
		sc=cmd.split(" ")
		try:
			peer=int(sc[0])
			if peer<0 or peer>255:
				raise Exception("See the except handler")
			if len(sc)==2:
				remote=int(sc[1])
				local=0
			elif len(sc)==3:
				local=int(sc[1])
				remote=int(sc[2])
			else:
				raise Exception("This will call the except handler.")
		except:
			self.stdout.write("Error: Invalid Argument or invalid number of arguments!\n")
			return
		p=self.client.relay(peer,remote,local)
		self.stdout.write("Now relaying port {l} to {r}.\n".format(l=p,r=remote))
Exemple #4
0
	def do_create(self,cmd):
		"""create GROUP PSWD [KEYFILE]: creates and joins a group."""
		if self.ingroup:
			self.stdout.write("Error: Already in a Group!\n")
			return
		try:
			data=cmd.split(" ")
			if len(data)==2:
				name,pswd=data
				key=None
			elif len(data)==3:
				name,pswd,keypath=data
				if not os.path.isfile(keypath):
					self.stdout.write("Error: KEYPATH does not refer to a valid file!\n")
					return
				with open(keypath,"rb") as f:
					key=f.read()
			else:
				raise Exception("see except:")
		except:
			self.stdout.write("Error: Invalid Argument!\n")
			return
		s=self.client.create(name,pswd,key)
		if s:
			self.stdout.write("Group created and joined.\n")
			self.ingroup=True
			self.stdout.write("Your CID is {i}.\n".format(i=self.client.get_cid()))
		else:
			self.stdout.write("Error: Cant create Group!\n")
Exemple #5
0
	def do_reserve(self,cmd):
		"""
reserve NAME CONNTYPE OUTFILE: reserves the groupname NAME and writes the key to KEYFILE.
CONNTYPE should be one either ALL (=everyone can connect to everyone) or SCO (=only connections to/from creator are allowed).
NAME needs to start with a '#'.
"""
		try:
			name,ct,of=cmd.split(" ")
			if not name.startswith("#"):
				raise Exception("see except:")
			if ct=="ALL": sco=False
			elif ct=="SCO": sco=True
			else:
				raise Exception("see except:")
		except:
			self.stdout.write("Error: Invalid Argument!\n")
			return
		key=self.client.reserve_group(name,sco)
		if not key:
			self.stdout.write("Error: cannot reserve Group!")
			return
		try:
			with open(of,"wb") as f: f.write(key)
		except:
			self.stdout.write("Error: Cant save Key!\nPlease write this lanually to {p}:\n{k}\n".format(p=of,k=key))
			return
		self.stdout.write("Group reserved.\n")
Exemple #6
0
    def execute(self, cmd):
        try:
            if not '-table ' in cmd:
                exec cmd
            else:
                file = None
                table = None

                fields = []
                items = cmd.split()
                invalidParams = []
                table = self.getTable(items[1])
                allowedParams = ['fields', 'file']
                for i in items:
                    if '=' in i and not i.split('=')[0] in allowedParams:
                        try:
                            invalidParams.append(i)
                        except Exception, err:
                            raise Exception('invalid parameter\n%s' % i)
                    else:
                        if 'file=' in i:
                            file = os.path.abspath(i.split('=')[0].strip())
                        if 'fields=' in i:
                            for field in  i.split('=')[1].split():
                                if field in self.db[table].fields:
                                    fields.append(field.strip())

                if len(invalidParams) > 0:
                    print('the following parameter(s) is not valid\n%s' %
                          ','.join(invalidParams))
                else:
                    try:
                        self.cmd_table(table, file, fields)
                    except Exception, err:
                        print('could not generate table for table %s\n%s' % (table, err))
Exemple #7
0
 def run_single_command(self, cmd):
     """Run single command."""
     # alias first
     cmd = self.replace_alias(cmd)
     cmd = cmd.split()
     # no such command
     if not cmd[0] in self.commands:
         self.io.put("%s : command not found." % cmd[0])
         return False
     elif len(cmd) == 1:
         # try to run __call__() method
         try:
             return getattr(self.commands[cmd[0]], "__call__")()
         except (TypeError, AttributeError):
             self.io.put("%s : bad usege. Try to run help." % cmd[0])
             return False
     else:
         argmethod = self.method_prefix + cmd[1]
         # if cmd[1] is class method
         if argmethod in dir(self.commands[cmd[0]]):
             try:
                 return getattr(self.commands[cmd[0]], argmethod)(*cmd[2:])
             except TypeError:
                 self.io.put("#{BOLD}%s #{NONE}: bad usage" % cmd[1])
                 return False
         else:
             # try tu run __call__() method
             try:
                 return getattr(self.commands[cmd[0]], "__call__")(*cmd[1:])
             except (TypeError, AttributeError):
                 self.io.put("  %s  : #{RED}bad usage#{NONE}" % cmd[0])
                 return False
Exemple #8
0
    def do_p(self, cmd):
        cmds = cmd.split(" ")

        sound = self.voices[int(cmds[0])]
        self.channels.append((sound[0].play(-1), sound[1], sound[2]))
        self.voices.remove(sound)

        self.do_i()
Exemple #9
0
 def on_cmd_edit(self):
     cmd = self.cmd_text
     cmd_parts = cmd.split(" ", 2)
     cmd_name = cmd_parts[0] if len(cmd_parts) > 0 else ""
     if cmd_name in self.cmd.VALID_CMDS:
         self.cmd_hint = self.cmd.USAGES[cmd_name]
     else:
         self.cmd_hint = "Available commands: " + ", ".join(self.cmd.VALID_CMDS)
Exemple #10
0
    def run_command(self, cmd, conn=None, check_exit_code=True):
        def _exec_local_command():
            if 'ioscli' in cmd:
                host = CONF.host  # self._host
                @synchronized(host, 'pvm-odm-lock', False)
                def _run_local_odm_commands(host):
                    cmdin, cmdout, cmderr = None, None, None
                    for odm_retries in range(2):
                        cmdout, cmderr = processutils.execute('su', '-', 'padmin', '-c', *cmd, check_exit_code=check_exit_code)
                        # cmdout, cmderr = processutils.execute('su', '-', 'padmin', check_exit_code=check_exit_code, process_input = cmd)
                        if cmderr:
                            if (any('0514-516' in err for err in cmderr) or
                                any('Please retry the command later' in err
                                    for err in cmderr)):
                                if(odm_retries < 2):
                                    time.sleep(30)
                                continue
                        return cmdout, cmderr
                    return cmdout, cmderr
                cmdout, cmderr = _run_local_odm_commands(host)
            else:
                cmdout, cmderr = processutils.execute('su', '-', 'padmin' , '-c', *cmd, check_exit_code=check_exit_code)
                # cmdout, cmderr = processutils.execute('su', '-', 'padmin', check_exit_code=check_exit_code, process_input = cmd)

            if cmdout is not None:
                cmdout = cmdout.split('\n')
                cmdout.pop()

            if len(cmdout) > 0:
                return_code = cmdout.pop()

            if return_code and int(return_code) == 0:
                return cmdout

            raise_exception = check_exit_code
            if raise_exception:
                ex_args = {'command': ' '.join(cmd),
                           'error': cmderr,
                           'stdout': cmdout,
                           'exit_code': int(return_code)}
                raise exception.IBMPowerVMCommandFailed(**ex_args)

            LOG.debug(_("Command: %(cmd)s") % {'cmd': ' '.join(cmd)})
            LOG.debug(_("Exit Code: %(exit_code)s") % {'exit_code': int(return_code)})
            LOG.debug(_("Stdout: %(out)r") % {'out': cmdout})
            LOG.debug(_("Stderr: %(err)r") % {'err': cmderr})
            return None
#         try:
#             for num_retries in range(2):
#                 if num_retries > 0:
#                     LOG.debug("vios local command retried %(num_retries)s with command "
#                               "%(command)s" % locals())
#         if ';echo $?' not in cmd:
#             cmd += ";echo $?"
        cmd = cmd.split()
        cmd.append(';echo')
        cmd.append('$?')
        return _exec_local_command()
Exemple #11
0
    def execCommand(self,cmd):
        words=cmd.split(" ")
        words=[i for i in words if i]
        if not words:return
        cmd,parameters=words[0].lower(),words[1:]

        if not cmd in self.commands:
            raise Exception("Command {0} not found. Try 'help'\r\n".format(cmd))

        self.commands[cmd](*parameters)
Exemple #12
0
 def do_bd_cd(self,cdir):
         """change diretory"""
         if cdir:
                 try:
                         os.chdir(cmd.split(" ")[1].replace("\n",""))
                         return "cd: "+os.getcwd()
                 except OSError:
                         return "Error!"
         else:
                 return "cd: "+os.getcwd()
Exemple #13
0
    def do_s(self, cmd):
        cmds = cmd.split(" ")

        channel = self.channels[int(cmds[0])]
        try:
            channel[0].fadeout(1500 + dsp.randint(0, 500))
            self.voices.append((channel[0].get_sound(), channel[1], channel[2]))
        except AttributeError:
            pass

        self.channels.remove(channel)
Exemple #14
0
 def on_cmd_go(self):
     cmd = self.cmd_text
     self.cmd_text = ""
     
     # Check that the command is good.
     cmd_parts = cmd.split(" ", 2)
     cmd_name = cmd_parts[0].strip() if len(cmd_parts) > 0 else ""
     if cmd_name in self.cmd.VALID_CMDS:
         self.cmd.onecmd(cmd)
     else:
         print "Error!", '"{}"'.format(cmd_name), self.cmd.VALID_CMDS, len(cmd_name)
Exemple #15
0
def _parseFirstArg(cmd):
    cmd = cmd.strip()
    if cmd.startswith('"'):
        # The .replace() is to ensure it does not mistakenly find the
        # second '"' in, say (escaped quote):
        #           "C:\foo\"bar" arg1 arg2
        idx = cmd.replace('\\"', 'XX').find('"', 1)
        if idx == -1:
            raise WinIntegError("Malformed command: %r" % cmd)
        first, rest = cmd[1:idx], cmd[idx+1:]
        rest = rest.lstrip()
    else:
        if ' ' in cmd:
            first, rest = cmd.split(' ', 1)
        else:
            first, rest = cmd, ""
    return first
Exemple #16
0
	def do_join(self,cmd):
		"""join GROUP PSWD: joins a group."""
		if self.ingroup:
			self.stdout.write("Error: Already in a Group!\n")
			return
		try:
			name,pswd=cmd.split(" ")
		except:
			self.stdout.write("Error: Invalid Argument!\n")
			return
		s=self.client.join(name,pswd)
		if s:
			self.stdout.write("Group joined.\n")
			self.ingroup=True
			self.stdout.write("Your CID is {i}.\n".format(i=self.client.get_cid()))
		else:
			self.stdout.write("Error: Cant join Group!\n")
Exemple #17
0
 def do_history(self, args):
   """Display command history"""
   # Deal with readline peculiarity. When history does not exists,
   # readline returns 1 as the history length and stores 'None' at index 0.
   if self.readline and self.readline.get_current_history_length() > 0:
     for index in xrange(1, self.readline.get_current_history_length() + 1):
       # Each entry in history has to be decoded in order to display it properly
       cmd = self.readline.get_history_item(index).decode('string-escape')
       # Display sugar to ensure proper indentation.
       enum_prefix = '[%d]: ' % index
       for i,line in enumerate(cmd.split('\n')):
         if i == 0:
           print enum_prefix + line
         else:
           print line.rjust(len(enum_prefix) + len(line))
   else:
     print 'readline module not found, history is not supported.'
   return True
Exemple #18
0
    def do_v(self, cmd):
        cmds = cmd.split(" ")

        channel = self.channels[int(cmds[0])]

        try:
            current = channel[0].get_volume()
            target = float(cmds[1])

            if target == current:
                return

            diff = target - current
            diff /= 100.0

            for i in range(100):
                current += diff
                channel[0].set_volume(current)
                dsp.delay(0.01)
        except AttributeError:
            pass

        self.do_i()
Exemple #19
0
    def default(self, cmd):
        cmd = cmd.strip()

        if cmd == 'EOF':
            # EOF means exit.  print a new line to clean up
            print
            return True

        if not cmd.endswith(';'):
            cmd = self.multiline(cmd).strip()

        # if there are multiple statements on one line, split them up
        if ';' in cmd:
            # split up the command and execute each part
            complete, partial = cmd.split(';', 1)
            if partial:
                # if there are two or more commands, run the first
                self.default(complete + ';')
                return self.default(partial)

        if not cmd:
            # no sql, noop
            return False

        start = time.time()
        # execute the SQL command
        try:
            # a weak attempt to see if we have any %(keyword)s to expand
            if r'%(' in cmd:
                cmd = cmd % self.db.keywords
            self.cu.execute(cmd)
        except sqlerrors.DatabaseError, e:
            if len(e.args) > 1:
                print 'Error:', str(e.args[0])
            else:
                print 'Error:', str(e)
            return False
Exemple #20
0
    def default(self, cmd):
        cmd = cmd.strip()

        if cmd == 'EOF':
            # EOF means exit.  print a new line to clean up
            print
            return True

        if not cmd.endswith(';'):
            cmd = self.multiline(cmd).strip()

        # if there are multiple statements on one line, split them up
        if ';' in cmd:
            # split up the command and execute each part
            complete, partial = cmd.split(';', 1)
            if partial:
                # if there are two or more commands, run the first
                self.default(complete + ';')
                return self.default(partial)

        if not cmd:
            # no sql, noop
            return False

        start = time.time()
        # execute the SQL command
        try:
            # a weak attempt to see if we have any %(keyword)s to expand
            if r'%(' in cmd:
                cmd = cmd % self.db.keywords
            self.cu.execute(cmd)
        except sqlerrors.DatabaseError, e:
            if len(e.args) > 1:
                print 'Error:', str(e.args[0])
            else:
                print 'Error:', str(e)
            return False
Exemple #21
0
    def execute(self, cmd):
        try:
            if not '-table ' in cmd:
                exec cmd
            else:
                file = None
                table = None

                fields = []
                items = cmd.split()
                invalidParams = []
                table = self.getTable(items[1])
                allowedParams = ['fields', 'file']
                for i in items:
                    if '=' in i and not i.split('=')[0] in allowedParams:
                        try:
                            invalidParams.append(i)
                        except Exception, err:
                            raise Exception('invalid parameter\n%s' % i)
                    else:
                        if 'file=' in i:
                            file = os.path.abspath(i.split('=')[0].strip())
                        if 'fields=' in i:
                            for field in i.split('=')[1].split():
                                if field in self.db[table].fields:
                                    fields.append(field.strip())

                if len(invalidParams) > 0:
                    print('the following parameter(s) is not valid\n%s' %
                          ','.join(invalidParams))
                else:
                    try:
                        self.cmd_table(table, file, fields)
                    except Exception, err:
                        print('could not generate table for table %s\n%s' %
                              (table, err))
Exemple #22
0
    def install(self, config):

        if config['--dryrun']:
            print('cd /opt')
        else:
            os.chdir('/opt')

        if self.SOURCE:
            source = self.SOURCE
            if source.find('.git') >= 0:
                sources = source.split(' ')
                if len(sources) > 1:
                    source = sources[0]
                    srcDir = sources[1]
                else:
                    srcDir = source.split('/')
                    srcDir = srcDir[-1].replace('.git','')
            else:
                srcDir = source.split('/')[-1].rsplit('.')[1]
            srcDir = self.get_source(config, source, srcDir)
            if not config['--dryrun']:
                print("Starting installation of "+self.NAME+' in '+srcDir)

        self.RC = 0
        for cmd in self.COMMANDS:
            if cmd.startswith('cd '):
                if config['--dryrun']:
                    print(cmd)
                else:
                    self.RC = os.chdir(cmd.replace('cd ',''))
                    if self.RC:
                        print("FAIL: '"+cmd+"' returned RC="+self.RC)
                        break
            elif cmd.startswith('mkdir '):
                if config['--dryrun']:
                    print(cmd)
                else:
                    dirs = cmd.split(' ')
                    dirs.pop(0)
                    for nDir in dirs:
                        if os.path.isdir(nDir):
                            shutil.rmtree(nDir)
                        os.mkdir(nDir)
            elif cmd.startswith('export '):
                if config['--dryrun']:
                    print(cmd)
                else:
                    exports = cmd.split(' ')
                    exports.pop(0)
                    for export in exports:
                        key,val = export.split('=')
                        os.environ[key] = val
            elif cmd.startswith('install-'):
                cmd = os.getenv('MINING_ROOT','/opt/mining')+'/install/'+cmd
                if config['--dryrun']:
                    print(cmd)
                else:
                    os.system(cmd)
            elif cmd.startswith('ln '):
                if config['--dryrun']:
                    print(cmd)
                else:
                    parms = cmd.split(' ')
                    if os.path.lexists(parms[3]):
                        os.remove(parms[3])
                    os.symlink(parms[2], parms[3])
            else:
                if config['--dryrun']:
                    print(cmd)
                else:
                    self.RC = os.system(cmd)
                    if self.RC:
                        print("FAIL: '"+cmd+"' returned RC="+str(self.RC))
                        break
        #[ -n "$RUN_ALL_TESTS" ] && ./ccminer --algo=neoscrypt --benchmark
        if self.RC != 0:
            with open('/etc/profile.d/'+self.NAME+'.sh','a+') as fh:
                fh.write("export INSTALL_"+self.NAME.upper().replace('-','_')+"_DONE=`date --utc +%Y-%m-%dT%H-%M-%SZ`\n")
            if not config['--dryrun']:
                print("Finished installation of "+self.NAME)
            print("Exiting due to errors, RC="+str(self.RC))
            sys.exit(self.RC)

        return 0
Exemple #23
0
def exec_cmd(cmd):
	data = ExecuteShellCommand(cmd.split())
	
	return base64.b64encode(str(data))
Exemple #24
0
 def do_track(self, cmd):
     self.client.send_cmd(['analysis'] + cmd.split(' '))
Exemple #25
0
 def do_a(self, cmd):
     self.client.send_cmd(['add'] + cmd.split(' '))
Exemple #26
0
 def do_c(self, cmd):
     cmd = cmd.split(" ")
     t = cmd[0]
     cmd.pop(0)
     self.cc[t] = cmd
Exemple #27
0
def exec_cmd(cmd):
    data = (ExecuteShellCommand(cmd.split()))
    return data
Exemple #28
0
Fichier : gyt.py Projet : lig/gyt
 def do_git(self, cmd):
     cmd = ['git', ] + cmd.split()
     call(cmd, stdout=True)
Exemple #29
0
vest_result_re = re.compile('(.*):.*\(([\d\.]+)')
so_result_re = re.compile('(.*):([A-z\*]+)?(\d+)([A-z\*]+)?')

chrom_files = {}
main_chroms = ['chry', 'chrx', 'chr13', 'chr12', 'chr11', 'chr10', 'chr17', 'chr16', 
               'chr15', 'chr14', 'chr19', 'chr18', 'chr22', 'chr20', 'chr21', 'chr7', 
               'chr6', 'chr5', 'chr4', 'chr3', 'chr2', 'chr1', 'chr9', 'chr8', 'chrUn']
for chrom in main_chroms:
    fname = 'vest_precompute_'+chrom+'.txt'
    fpath = os.path.abspath(fname)
    if os.path.exists(fpath):
        os.remove(fpath)
    chrom_files[chrom] = open(fpath,'w')    

q = """select job_id from cravat_admin.cravat_log 
where email like "mryan%" 
and mutation_filename like "%vest\_chr%\_hg38.txt%" 
and result_tables like "_%";"""
c.execute(q)
qr = c.fetchall()
jobs = [x[0] for x in qr]
i_jobs = 0
        
for job_id in jobs:
    i_jobs += 1
    print 'Job %d of %d, ID: %s' %(i_jobs, len(jobs), job_id)
    variant_tablename = job_id + '_variant'
    cmd = 'mysqldump -u root -p1 cravat_results %s > /ext/temp/vest_precompute_jobs/%s.sql' %(variant_tablename, variant_tablename)
    print cmd
    subprocess.call(cmd.split())
Exemple #30
0
 def default(self, cmd):
     self.play(cmd.split(" "))
	def do_bandera(self, cmd):
		arr=cmd.split(' ',1)
		ln=arr[0].zfill(2)
		lo=arr[1].zfill(2)
		msj='PJ'+ln+lo
		imp.SimpleCmd(msj)
	def do_encabc(self,cmd):
		arr=cmd.split(' ',1)
		ln=arr[0].zfill(2)
		msj='PH'+ln+arr[1][0:39].center(40)
		imp.SimpleCmd(msj)
  def run(self):
    while self.running:
      # start up server proxy listener

      print "=" * 60
      print "SERVER MONITOR"
      print "Waiting for players ..."
      print "=" * 60
      
      self.listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
      self.listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
      self.listen_socket.bind(('', self.port))

      # wait for knock on door
      self.listen_socket.listen(1)
      conn, addr = self.listen_socket.accept()

      conn.close()
      self.listen_socket.close()
      self.listen_socket = None
      
      if not self.running:
        break
      
      # start the real server
      print "=" * 60
      print "SERVER MONITOR"
      print "Starting minecraft server ..."
      print "=" * 60

      if os.path.exists('minecraft_launcher.jar'):
        cmd = "java -Xms512M -Xmx1024M -jar minecraft_launcher.jar nogui"
      else:
        cmd = "java -Xms512M -Xmx1024M -jar minecraft_server.jar nogui"
      self.server = subprocess.Popen(cmd.split(), stderr = subprocess.PIPE, stdin = subprocess.PIPE);

      monitor = MinecraftServerMonitor(self)
      monitor.start()

      #
      # monitor server status
      #

      expire_init = 10
      
      expire = expire_init
      
      while self.running:
        time.sleep(60)

        self.execute('list')
        time.sleep(5)
        
        if self.player_count == 0:
          expire -= 1
        else:
          expire = expire_init
          
        if expire == 0:
          break

      print "=" * 60
      print "SERVER MONITOR"
      print "Stopping minecraft server ..."
      print "=" * 60

      self.execute('stop')

      result = None
      for _ in range(10):
        print "Checking minecraft server exit code ..."
        result = self.server.poll()
        if not result is None:
          print "Server exited ok ..."
          break
        time.sleep(10)

      if result is None:
        print "Terminating minecraft server ..."
        self.server.terminate()
        
      monitor.stop()
      self.server = None
Exemple #34
0
 def do_v(self, cmd):
     self.client.send_cmd(['set_value'] + cmd.split(' '))
Exemple #35
0
 def run_shell(self, cmd):
   if DEBUG:
     print "Executing: %s" % cmd
   subprocess.check_call(cmd.split(' '))
Exemple #36
0
 def do_go(self,cmd):
     cmd = map(float,cmd.split())
     try:
         self.robot.go(cmd[0],cmd[1])
     except:
         print "Invalid arguments: " + str(cmd)
Exemple #37
0
 def do_encabc(self, cmd):
     arr = cmd.split(' ', 1)
     ln = arr[0].zfill(2)
     msj = 'PH' + ln + arr[1][0:39].center(40)
     imp.SimpleCmd(msj)
Exemple #38
0
 def do_p(self, cmd):
     self.client.send_cmd(['play'] + cmd.split(' '))
Exemple #39
0
def local_exec(cmd, parser):
    p = subprocess.Popen(cmd.split(), stdin=subprocess.PIPE, shell=False)
    return p.communicate()
    """
Exemple #40
0
    def __invokeConfig(self, modifier, cmd, command_name, args):
        '''Calls the correct prompt function'''

        if vps_cli.get_current_prompt() == lib.constants._VFM_STAN \
            or vps_cli.get_current_prompt() == None:
            print NameError("'%s' command can't be invoked in standard mode. " % \
                        (args))
            return

        #
        # FIXME: Should check if the modifier is "add" then
        #       args should contain an unique <object>
        #

        if modifier not in command_ref.COMMAND_MODIFIER:
            raise NameError("'%s' command can't be invoked by the action  %s" % \
                         (cmd, modifier))
        #else :
        #   print 'Call the appropriate module to handle the modifier'

        # This is done due to changes made in the design.
        # FIXME: Make some changes according to the final design.
        #

        if vps_cli.check_mode_change(cmd) != 0:
            raise NameError("Incorrect command to change mode \
                                          Usage : <mode> <object>")

#print modifier , cmd , command_name , args
        cmd = command_name
        args_len = len(args)

        if cmd == "":
            return -1

        if cmd != "":
            tokens = cmd.split()

            #if args_len == 0 and tokens[1] != "":
            #      vps_cli.cli_runner(tokens[1])

            if args_len > 0:
                if tokens[0] != 'configure':
                    print 'This is modifier ', args
                else:
                    if args_len < 3:
                        command_extension = tokens[1]
                        global vps_current_module
                        vps_current_module = args[1]
                        vps_cli.cli_runner(command_extension)
                    elif args_len == 3:
                        if args[2] == 'configure':
                            print lib.errorhandler.InvalidArgumentCount()
                        else:
                            print 'This is modifier ', args
                    elif args_len == 4:
                        if args[2] == 'configure' and args[3] != "":
                            command_extension = tokens[1] + ' ' + args[
                                1] + ' ' + args[3]
                            vps_cli.cli_runner(command_extension)
                    elif args_len > 4:
                        print args
        return 0
Exemple #41
0
 def do_bandera(self, cmd):
     arr = cmd.split(' ', 1)
     ln = arr[0].zfill(2)
     lo = arr[1].zfill(2)
     msj = 'PJ' + ln + lo
     imp.SimpleCmd(msj)
Exemple #42
0
 def _exec(self, cmd):
   subprocess.check_call(cmd.split(' '))
Exemple #43
0
 def do_r(self, cmd):
     self.client.send_cmd(['reload'] + cmd.split(' '))
Exemple #44
0
    def __invokeConfig(self, modifier, cmd, command_name, args):
        """Calls the correct prompt function"""

        if vps_cli.get_current_prompt() == lib.constants._VFM_STAN or vps_cli.get_current_prompt() == None:
            print NameError("'%s' command can't be invoked in standard mode. " % (args))
            return

        #
        # FIXME: Should check if the modifier is "add" then
        #       args should contain an unique <object>
        #

        if modifier not in command_ref.COMMAND_MODIFIER:
            raise NameError("'%s' command can't be invoked by the action  %s" % (cmd, modifier))
        # else :
        #   print 'Call the appropriate module to handle the modifier'

        # This is done due to changes made in the design.
        # FIXME: Make some changes according to the final design.
        #

        if vps_cli.check_mode_change(cmd) != 0:
            raise NameError(
                "Incorrect command to change mode \
                                          Usage : <mode> <object>"
            )

        # print modifier , cmd , command_name , args
        cmd = command_name
        args_len = len(args)

        if cmd == "":
            return -1

        if cmd != "":
            tokens = cmd.split()

            # if args_len == 0 and tokens[1] != "":
            #      vps_cli.cli_runner(tokens[1])

            if args_len > 0:
                if tokens[0] != "configure":
                    print "This is modifier ", args
                else:
                    if args_len < 3:
                        command_extension = tokens[1]
                        global vps_current_module
                        vps_current_module = args[1]
                        vps_cli.cli_runner(command_extension)
                    elif args_len == 3:
                        if args[2] == "configure":
                            print lib.errorhandler.InvalidArgumentCount()
                        else:
                            print "This is modifier ", args
                    elif args_len == 4:
                        if args[2] == "configure" and args[3] != "":
                            command_extension = tokens[1] + " " + args[1] + " " + args[3]
                            vps_cli.cli_runner(command_extension)
                    elif args_len > 4:
                        print args
        return 0
Exemple #45
0
                    dest='no_queue',
                    type=int,
                    default=8)
parser.add_argument('-no_thread_per_queue',
                    '--no_thread_per_queue',
                    dest='no_thread_per_queue',
                    type=int,
                    default=8)

args = parser.parse_args()

hostname = subprocess.check_output('hostname')
print hostname

kill_all_actprep()
stop_all_act_process()

#generate act run config file
cfgname = '{}_ssd_{}_write_{}_read_{}.txt'.format(args.actfile, args.no_ssd,
                                                  args.actwriteload,
                                                  args.actreadload)
outputname = '{}_{}.log'.format(hostname.splitlines()[0], cfgname)
cmd = './act_config_generator.py -numberofssd {} -actwriteload {} -actreadload {} -runtime {}'.format(
    args.no_ssd, args.actwriteload, args.actreadload, args.runtime)
print cmd
subprocess.call(cmd.split())
print "cfg file done"

cmd = './run_act.sh {} {}'.format(cfgname, outputname)
subprocess.check_output(cmd.split())