示例#1
0
文件: svn2feed.py 项目: vocho/openqnx
    def _get_item_dict(self, revision):
        revision = str(revision)

        cmd = [self.svnlook_cmd, 'info', '-r', revision, self.repos_path]
        child_out, child_in, child_err = popen2.popen3(cmd)
        info_lines = child_out.readlines()
        child_out.close()
        child_in.close()
        child_err.close()

        cmd = [self.svnlook_cmd, 'changed', '-r', revision, self.repos_path]
        child_out, child_in, child_err = popen2.popen3(cmd)
        changed_data = child_out.read()
        child_out.close()
        child_in.close()
        child_err.close()

        desc = ("\nRevision: %s\nLog: %sModified: \n%s"
                % (revision, info_lines[3], changed_data))

        item_dict = {
            'author': info_lines[0].strip('\n'),
            'title': "Revision %s" % revision,
            'link': self.item_url and "%s?rev=%s" % (self.item_url, revision),
            'date': self._format_updated_ts(info_lines[1]),
            'description': "<pre>" + desc + "</pre>",
            }

        return item_dict
示例#2
0
    def test_popen3(self):
        if os.name == 'posix':
            r, w, e = popen2.popen3([self.cmd])
            self.validate_output(self.teststr, self.expected, r, w, e)

        r, w, e = popen2.popen3(self.cmd)
        self.validate_output(self.teststr, self.expected, r, w, e)
示例#3
0
 def make_rss_item_desc(self):
     cmd = "svnlook info -r " + self.revision + " " + self.repos_path
     out, x, y = popen2.popen3(cmd)
     cmd_out = out.readlines()
     Author = "\nAuthor: " + cmd_out[0]
     Date = "Date: " + cmd_out[1]
     New_Revision = "Revision: " + self.revision
     Log = "Log: " + cmd_out[3]
     out.close()
     x.close()
     y.close()
     
     cmd = "svnlook changed -r " + self.revision + " " + self.repos_path
     out, x, y = popen2.popen3(cmd)
     cmd_out = out.readlines()
     changed_files = "Modified: \n"
     for item in cmd_out:
         changed_files = changed_files + item
     item_desc = Author + Date + New_Revision + "\n" + \
                 Log + changed_files
     out.close()
     x.close()
     y.close()
     
     return item_desc
示例#4
0
文件: gen.py 项目: andreytata/exp57
def generate_msvc_vcproj(path):
  print "<msvc><pro> '%s'"%path
  global temp, work, sdir, pro_dict
  full=path
  path,name=os.path.split(path)
  proj=is_pro.match(name).groups()[0]+'.vcproj'
  os.chdir(path)                                                # set current working directory
  gend = 'gen.'+os.environ["QMAKESPEC"]                         # output folder name
  outd = os.path.join(work,gend+path[len(sdir):])               # extract output folder
  outf = os.path.join(outd,proj)                                # create output file name
  outp = os.path.join(outd,name)
  #print "  * here = '%s'"%os.getcwd()
  #print "  * work = '%s'"%str((work,gend,path[len(sdir):]))
  #print "  * outd = '%s'"%outd
  #print "  * outf = '%s'"%outf
  msvc_project_files.append(outf)
  #print "  * qmsp = '%s'"%os.environ["QMAKESPEC"]
  mkpath(outd)                                                  # create output folder
  file(outp,"w")                                                # create empty project file
  if pro_dict[full]["TEMPLATE"]=='app':
    o,i,e = popen3("qmake %s -t vcapp -o %s"%(full,outf))       # use qmake, to generate application vcproj
  elif pro_dict[full]["TEMPLATE"]=='lib':
    o,i,e = popen3("qmake %s -t vclib -o %s"%(full,outf))       # use qmake, to generate library vcproj
  else:
    raise gen_exception("unsupported TEMPLATE='%s'"%str(
         pro_dict[full]["TEMPLATE"]))
示例#5
0
文件: agenda.py 项目: tonyli71/qpid
def main():
    parser = OptionParser()
    parser.add_option("-r",
                      "--revision",
                      dest="revision",
                      action="store",
                      type="string",
                      help="The first revision to generate logs for")

    (options, args) = parser.parse_args()

    # Check that we have what's necessary

    notfound = re.compile('^which')
    for cmd in prereqs:
        (stdout, stdin, stderr) = popen3('which %s' % cmd)
        if (notfound.match(stderr.read())):
            parser.error(
                "Could not find command %s, try [apt-get|yum] install %s" %
                (cmd, cmd))

    if (options.revision == None):
        parser.error("svn revision must be specified")

    print(get_commits(options.revision))
    print "h2. Jiras"
    print(get_jiras())
示例#6
0
def get_gdal_config(option, gdal_config='gdal-config'):
    
    command = gdal_config + " --%s" % option
    try:
        import subprocess
        command, args = command.split()[0], command.split()[1]
        p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
        from sys import version_info
        if version_info >= (3,0,0):
            r = p.stdout.readline().decode('ascii').strip()
        else:
            r = p.stdout.readline().strip()
        p.stdout.close()
        p.wait()

    except ImportError:
        
        import popen2
        
        p = popen2.popen3(command)
        r = p[0].readline().strip()
        if not r:
            raise Warning(p[2].readline())
    
    return r
示例#7
0
def cmdoutput(command, strip=FALSE, waitpid=TRUE, returnerror=FALSE):
    """ Read the complete output of a command. """
    pipe = popen3(command)

    # os.wait is not available on the win32 platform so it is necessary to set this values
    if (sys.platform == "win32"):
        waitpid = FALSE

    if (returnerror == TRUE):
        output = pipe[2].readlines()
    else:
        output = pipe[0].readlines()

    if (strip == TRUE):
        output = striplist(output)

    if (pipe[0] != None):
        pipe[0].close()
    if (pipe[1] != None):
        pipe[1].close()
    if (pipe[2] != None):
        pipe[2].close()
    if (waitpid == TRUE):
        os.wait()
    del pipe
    pipe = None
    return output
示例#8
0
def gccFortranLibs():
    """Test which gcc Fortran startup libraries are required.
    This should probably move into SCons itself, but is kind of hacky.
    """

    libs = ["g2c"]
    cmd = "gcc -v"

    try:
        import subprocess
    except ImportError:
        try:
            import popen2

            stderr = popen2.popen3(cmd)[2].read()
        except OSError:
            return libs
    else:
        p = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE)
        stderr = p.stderr.read()
    m = re.search("gcc version (\d\.\d)", stderr)
    if m:
        gcc_version = m.group(1)
        if re.match("4.[^0]", gcc_version):
            libs = ["gfortranbegin"]
        elif gcc_version in ("3.1", "4.0"):
            libs = ["frtbegin"] + libs

    return libs
示例#9
0
 def _curvol():
     cmd = 'amixer get Master'
     (stdout, stdin, stderr) = popen2.popen3(cmd)
     for line in stdout:
         m = amixer_volline.match(line)
         if m is not None:
             return int(m.group(2))
示例#10
0
    def OnMenuFORTHsystem(self, event):
        self.fileDlg = wx.FileDialog(parent=self,
                                     message="Choose your FORTH system",
                                     defaultDir="/usr/bin",
                                     defaultFile="gforth",
                                     wildcard="*.*",
                                     style=wx.OPEN)
        try:
            if self.fileDlg.ShowModal() == wx.ID_OK:
                self.fORTHsystem = self.fileDlg.GetPath()
        finally:
            self.fileDlg.Destroy()

        try:
            #self.forthStdOut, self.forthStdIn, self.forthStdErr = popen2.popen3('/usr/local/bin/bigforth')
            self.forthStdOut, self.forthStdIn, self.forthStdErr = popen2.popen3(self.fORTHsystem)
            """Clear contents of output window."""
            self.forthTerminalCtrl.Clear()
            self.StartFromForthReceiveThread()
            #self.forthStdIn.write('\r')    # CR
            #self.forthStdIn.write('\n')    # LF

            if not self.alive.isSet():
                self.forthStdOut.close()        #cleanup
                self.forthStdIn.close()
                self.forthStdErr.close()
                self.Close()
            self.pipeExists=True

            self.forthTerminalCtrl.SetFocus()
            
        except:
            self.pipeExists=False
示例#11
0
def call(request) :
  if request.method == "POST":
    token = request.POST['token']
    channel = request.POST['userid']
    message = request.POST['vminfo']
    #ami_index = request.POST['ami_index']
    ami_index = simplejson.loads(message)['ami-launch-index']
    instance = Instances.objects.get(instance_token=token,ami_index=ami_index)
    
    if instance.launch_response_time == None  :
      instance.current_state = "running"
      instance.launch_response_time = datetime.datetime.now()
      instance.public_dns_name = simplejson.loads(message)['public-ipv4']
      instance.private_dns_name = simplejson.loads(message)['local-ipv4']
      instance.save()
      node_path = Configs.objects.get(key="node_path").value
      sayjs_path = Configs.objects.get(key="say.js_path").value
      if simplejson.loads(message)['event_type'] == "instasnce_lunched" :
        #sendPasswordEmail(simplejson.loads(message)['public-ipv4'],simplejson.loads(message)['linuxusername'], simplejson.loads(message)['linuxuserpassword'])
        sendPasswordEmail(channel,message)
        sendWebhookCall(channel,message)
        notice_msg = "instance %s was launched with ip %s" % ( simplejson.loads(message)['instance-id'] , simplejson.loads(message)['public-ipv4'] )
        r, w, e = popen2.popen3('%s %s %s "%s"' % (node_path, sayjs_path, channel, notice_msg))
        logging.debug(e.readlines())
        logging.debug(r.readlines())
        r.close()
        e.close()
        w.close()
      return HttpResponse("ok")
    else :
      return HttpResponse("launch_response_time is not null")
  else :
    return HttpResponse("invalid protocol")
示例#12
0
def setup_dump(args):
    p = popen2.popen3(popen_fmt % args['unpackpath'])
    p[1].close()
    ln = p[0].readline()
    while ln:
        if ln.strip() == '**** PyPI2PkgSys ****': break
        ln = p[0].readline()
    if ln:  # We got result.
        c = p[0].readline()
        p[0].close()
        newargs = eval(c)
        for k in newargs.keys():
            if k not in args: args[k] = newargs[k]
            else: raise RuntimeError, 'args key conflict: %s' % k
        p[2].close()
    else:  # Some error encountered.
        p[0].close()
        cr = re.compile('\w+Error:\s+')
        ln = p[2].readline()
        while ln:
            if cr.match(ln):
                p[2].close()
                raise RuntimeError, ln.strip()
            ln = p[2].readline()
        raise RuntimeError
示例#13
0
文件: regress.py 项目: Azaraf/Honeyd
    def start_honeyd(self, filename):
        (fw, fr, self.fe) = popen2.popen3(self.command % filename, 0)

        fw.close()
        fr.close()
        self.set_nonblock(self.fe.fileno())
        time.sleep(2)
示例#14
0
文件: graphviz.py 项目: nsi-iff/pyOLS
    def renderGraph(self, graph):
        """ Render 'graph'.
            If there is error text, an exception is raised.  Otherwise
            the rendered PNG is returned. """

        self.assertLayouterPresent()

        tool = os.path.join(config['graphviz_path'], self._layouter)

        # 2006-08-03 Seperate streams for output and error.
        #            Avoids problems with fonts not found.
        cmd = "%s -Tpng" %(tool)
        (pout, pin, perr) = popen2.popen3(cmd=cmd, mode="b")
        pin.write(graph)
        pin.close()

        data  = pout.read()
        pout.close()
        error = perr.read()
        perr.close()

        if error:
            raise PyolsEnvironmentError("The command %r produced text on "
                                        "stderr: %s" %(cmd, error))

        return data
示例#15
0
def get_gdal_config(option, gdal_config="gdal-config"):

    command = gdal_config + " --%s" % option
    try:
        import subprocess

        command, args = command.split()[0], command.split()[1]
        p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
        from sys import version_info

        if version_info >= (3, 0, 0):
            r = p.stdout.readline().decode("ascii").strip()
        else:
            r = p.stdout.readline().strip()
        p.stdout.close()
        p.wait()

    except ImportError:

        import popen2

        p = popen2.popen3(command)
        r = p[0].readline().strip()
        if not r:
            raise Warning(p[2].readline())

    return r
示例#16
0
 def runcmd(self,N,threadID,len=0):
     scmd=N
     r,w,e = popen2.popen3(scmd)
     self.queue.put([r.readlines(),e.readlines()])
     r.close()
     e.close()
     w.close()
示例#17
0
 def fetchList(self):
     (stdout, stdin, stderr) = popen3("%s --getfilelist '%s*.*'" % (self.bin, self.dir))
     list = stdout.readlines()
     # Useless gnokii prompt
     del list[0]
     # Get rid of whitespaces at the ends of the file name
     self.file_list = map(lambda x: x.strip(), list)
示例#18
0
文件: Utils.py 项目: LTD-Beget/nsd
def run_cmd(cmd, desc):
   #-- run a command using our own particular idiom
   global VERBOSE

   result = True		# T => ran without error reports, F otherwise

   if VERBOSE and len(desc) > 0:
      report_info('=> ' + desc)

   (cout, cin, cerr) = popen2.popen3(cmd)

   cin.close()

   output = cout.readlines()
   cout.close()
   if VERBOSE:
      report_info(''.join(output))

   errors = cerr.readlines()
   cerr.close()
   if len(errors) > 0:
      result = False
      report_error(''.join(errors))

   return result
示例#19
0
文件: genPlot.py 项目: kpj/GetClick
	def execCurl(self, threadNum):
		r, w, e = popen2.popen3( self.test_command % ( self.URL, threadNum, self.COUNTER ) )
		output = r.readlines()
		r.close()
		w.close()
		e.close()
		return output
示例#20
0
def cmdoutput(command, strip = FALSE, waitpid = TRUE, returnerror = FALSE):
    """ Read the complete output of a command. """
    pipe = popen3(command)

    # os.wait is not available on the win32 platform so it is necessary to set this values
    if (sys.platform == "win32"):
        waitpid = FALSE

    if (returnerror == TRUE):
        output = pipe[2].readlines()
    else:
        output = pipe[0].readlines()

    if (strip == TRUE):
        output = striplist(output)

    if (pipe[0] != None):
        pipe[0].close()
    if (pipe[1] != None):
        pipe[1].close()
    if (pipe[2] != None):
        pipe[2].close()
    if (waitpid == TRUE):
        os.wait()
    del pipe
    pipe = None
    return output
示例#21
0
文件: tests.py 项目: dsturnbull/unfs
    def testNodeDistrib(self):
        """
        Extract proz, stress test, make sure each node has at least 1/8 of tot.
        """

        os.system('tar zxf %s -C %s' % (self.tar, unfs.mountPoint))

        r, w, e = popen2.popen3('du --max-depth=1 %s' % \
            unfs.nodeMountPoint)

        sizes = []
        for line in r.readlines():
            size, _ = line.split('\t')
            sizes.append(int(size.replace('K', '')))
        r.close()
        w.close()
        e.close()

        nodeMinSize = os.stat(self.tar)[stat.ST_SIZE]/1024/8
        for size in sizes:
            self.assert_(size > nodeMinSize)

        os.system('rm -rf %s/%s' % (
            unfs.mountPoint,
            os.path.basename(self.tar).replace('.tar.gz', '')),
        )
示例#22
0
文件: tests.py 项目: dsturnbull/unfs
 def statFileCtime(self, fileName):
     """
     helper method, return ctime for file, from 'stat' program
     """
     r, w, e = popen2.popen3('stat %s | grep Change | awk \'{print $3}\'' \
         % fileName)
     return r.readlines()[0].strip()
示例#23
0
def fetch_config(option, gdal_config='gdal-config'):

    command = gdal_config + " --%s" % option

    try:
        import subprocess
        command, args = command.split()[0], command.split()[1]
        from sys import version_info
        if version_info >= (3, 0, 0):
            try:
                p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
            except OSError:
                import sys
                e = sys.exc_info()[1]
                raise gdal_config_error(e)
            r = p.stdout.readline().decode('ascii').strip()
        else:
            exec("""try:
    p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
except OSError, e:
    raise gdal_config_error, e""")
            r = p.stdout.readline().strip()
        p.stdout.close()
        p.wait()

    except ImportError:

        import popen2

        p = popen2.popen3(command)
        r = p[0].readline().strip()
        if not r:
            raise Warning(p[2].readline())

    return r
示例#24
0
 def runcmd(self, N, threadID, len=0):
     scmd = N
     r, w, e = popen2.popen3(scmd)
     self.queue.put([r.readlines(), e.readlines()])
     r.close()
     e.close()
     w.close()
示例#25
0
def B15Las():
    vals = [
        "Xerox", "Phaser 7400",
        datetime.now(), "B15", 0, 0, 0, 0, 0, 0, 0, 0, 0
    ]

    (o, i, e) = popen2.popen3("wget -qO- http://10.240.250.248/status.html")
    data = o.read()
    data = data.split("\n")

    if e.read() != " ":
        for i in range(len(data)):
            if data[i].find("<td>Page Count") != -1:
                vals[4] = int(data[i +
                                   1].strip("\r\n").strip("<td>").strip("</"))

        p = printer_admin(make=vals[0],
                          model=vals[1],
                          date=vals[2],
                          location=vals[3],
                          totalcount=vals[4],
                          colourcount=vals[5],
                          monocount=vals[6],
                          cyancount=vals[7],
                          magcount=vals[8],
                          yelcount=vals[9],
                          blackcount=vals[10],
                          drumcount=vals[11],
                          difftotal=vals[12])
        p.save()
示例#26
0
def T3Las():

	#STORE THE VALUES SOMEWHERE TEMPERARILY
	vals = ["Brother","HL4040CN",datetime.now(),"T3",0,0,0,0,0,0,0,0,0]
	
	(o,i,e) = popen2.popen3("wget -qO- http://10.240.251.34/etc/mnt_info.html?kind=item")
	data = o.read()
	data = data.split("\n")
	
	if e.read() != " ":
		for i in range(len(data)):
			if data[i].find("Total Page Count") != -1:
				vals[4]=int(data[i+2].strip("\r\n"))
			elif data[i].find("Color Page Count") != -1:
				vals[5]=int(data[i+2].strip("\r\n"))
			elif data[i].find("Monochrome Page Count") != -1:
				vals[6]=int(data[i+2].strip("\r\n"))
			elif data[i].find("Image Count Cyan (C)") != -1:
				vals[7] =int(data[i+2].strip("\r\n"))
			elif data[i].find("Image Count Magenta (M)") != -1:
				vals[8] =int(data[i+2].strip("\r\n"))
			elif data[i].find("Image Count Yellow (Y)") != -1:
				vals[9] =int(data[i+2].strip("\r\n"))
			elif data[i].find("Image Count Black (K)") != -1:
				vals[10]=int(data[i+2].strip("\r\n"))
			elif data[i].find("Drum Count") != -1:
				vals[11]=int(data[i+2].strip("\r\n"))
		
		p = printer_admin(make=vals[0],model=vals[1],date=vals[2],location=vals[3],totalcount=vals[4],colourcount=vals[5],monocount=vals[6],cyancount=vals[7],magcount=vals[8],yelcount=vals[9],blackcount=vals[10],drumcount=vals[11],difftotal=vals[12])
		p.save()
示例#27
0
def ldd(infiles):

    # Run ldd
    
    errors = []
    output = []
    command = ""
    for count, file in enumerate(infiles):
        if not os.path.exists(file):
            quit("could not find file %s" % file)
        
        stdout, stdin, stderr = popen3("ldd %s" % file)
        ####D
        #print "\tldd - OK"
        #recs = stderr.read()
        #print "\tldd len(errors)", len(recs)
        #errors.extend(map(lambda x: strip(x),recs))

        recs = stdout.readlines()
        #print "\tldd len(output)", len(recs)
        output.extend(map(lambda x: strip(x),recs))
        #print "\tldd - done"
        
    # Check for errors

    if len(errors) > 0:
        errlog = open("%(errorlog)s" % names,"w")
        for error in errors:
            errlog.write("%s\n" % error)
        errlog.close()    

    if len(output) == 0:
        quit("check %(errorlog)s\n" % names)

    # Extract paths and libraries found
    # Keep track of input files with problems
    
    index = 0
    paths = []
    problem = {}
    for s in output:
        if s == infiles[index]:
            file = s
            index += 1
        else:
            t = split(s,'=>')
            if len(t) == 2:
                lib  = split(t[0],'/').pop()
                path = split(t[1])[0]
                if not path in paths:
                    paths.append((lib,path))
                    
    # Write info to screen

    paths.sort()    
    for lib, path in paths:
        print "%-32s %s" % (lib,path)
                
    if len(errors) > 0:
        print "\nWarning: check %(errorlog)s\n" % names
示例#28
0
def fetch_config(option, gdal_config='gdal-config'):

    command = gdal_config + " --%s" % option

    try:
        import subprocess
        command, args = command.split()[0], command.split()[1]
        from sys import version_info
        if version_info >= (3,0,0):
            try:
                p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
            except OSError(e):
                raise gdal_config_error(e)
            r = p.stdout.readline().decode('ascii').strip()
        else:
            exec("""try:
    p = subprocess.Popen([command, args], stdout=subprocess.PIPE)
except OSError, e:
    raise gdal_config_error, e""")
            r = p.stdout.readline().strip()
        p.stdout.close()
        p.wait()

    except ImportError:
        
        import popen2
        
        p = popen2.popen3(command)
        r = p[0].readline().strip()
        if not r:
            raise Warning(p[2].readline())
    
    return r
示例#29
0
def setup_dump(args):
    p = popen2.popen3(popen_fmt % args['unpackpath'])
    p[1].close()
    ln = p[0].readline()
    while ln:
        if ln.strip() == '**** PyPI2PkgSys ****': break
        ln = p[0].readline()
    if ln: # We got result.
        c = p[0].readline()
        p[0].close()
        newargs = eval(c)
        for k in newargs.keys():
            if k not in args: args[k] = newargs[k]
            else: raise RuntimeError, 'args key conflict: %s' % k
        p[2].close()
    else: # Some error encountered.
        p[0].close()
        cr = re.compile('\w+Error:\s+')
        ln = p[2].readline()
        while ln:
            if cr.match(ln):
                p[2].close()
                raise RuntimeError, ln.strip()
            ln = p[2].readline()
        raise RuntimeError
def main(openerp_gtk_client_path):
	# ----- Escape if config file with client list doesn't exist
	print 'Reading customer list file...'
	customer_list_path = '%s/config/customer.list' % (os.path.dirname(sys.argv[0]))
	if not os.path.exists(customer_list_path):
		print 'Create "customer.list" file in "config" folder!'
		return False
	# ----- Open the config list file and extracts customers list
	config_file = open(customer_list_path,'r')
	customer_list_file = config_file.readlines()
	print 'Parding customer list file...'
	# ----- Create the bash windows parametrs, show it and keep the selection
	customer_list = ' '.join(cliente.split('\t')[0].replace('\n', '') for cliente in customer_list_file)
	print 'Creating data window...'
	bash_string = 'zenity --list --text="Select a line:" --column="Customers" %s' % (customer_list)
	result = popen2.popen3(bash_string)
	selected_customer = result[0].readlines()[0].replace('\n', '')
	# ----- Extracts the customer ip
	customer_ip = ''
	customer_port = '8070'
	for customers in customer_list_file:
		if customers.split('\t')[0] == selected_customer:
			customer_ip = customers.split('\t')[1]
			if len(customers.split('\t')) > 2:
				customer_port = customers.split('\t')[2]
	print 'Setting remote IP to', customer_ip.replace('\n', ''), '...'
	print 'Setting remote PORT to', customer_port.replace('\n', ''), '...'
	return customer_ip.replace('\n', ''), customer_port.replace('\n', '')
def run_osra(osra):
	sdf = " "    
	filedes, filename = tempfile.mkstemp(suffix='.png')

	if os.name=="posix":
		import pygtk
		pygtk.require('2.0')
		import gtk, gobject
		clipboard = gtk.clipboard_get()
		image=clipboard.wait_for_image()
		if not image:
			return sdf
		try:
			image.save(filename,"png")
		except:
			return sdf
	else:
		import ImageGrab
		image = ImageGrab.grabclipboard()
		if not image:
			return sdf
		try:
			image.save(filename)
		except:
			return sdf

	try:
		stdout, stdin, stderr = popen2.popen3('"%s" -f sdf %s' % (osra, filename))
	except:
		os.remove(filename)
		return sdf

	sdf = stdout.read()
	#os.remove(filename)
	return sdf
示例#32
0
 def start(self):
     """
     Starts local worker.
     """
     if _USE_SUBPROCESS:
         if sys.platform.startswith("win"):
             import win32process
             proc = subprocess.Popen(
                 self.command,
                 shell=False,
                 stdin=subprocess.PIPE,
                 stdout=subprocess.PIPE,
                 stderr=subprocess.PIPE,
                 universal_newlines=False,
                 creationflags=win32process.CREATE_NO_WINDOW,)
         else:
             proc = subprocess.Popen(
                 self.command,
                 shell=False,
                 stdin=subprocess.PIPE,
                 stdout=subprocess.PIPE,
                 stderr=subprocess.PIPE,
                 universal_newlines=False,)
         self.t = pptransport.CPipeTransport(proc.stdout, proc.stdin)
     else:
         self.t = pptransport.CPipeTransport(*popen2.popen3(self.command)[:2])
     self.pid = int(self.t.receive())
     self.t.send(str(self.pickle_proto))
     self.is_free = True
示例#33
0
def main():
    global options
    parser = OptionParser()
    parser.add_option("-r", "--revision", dest="revision", action="store",
                      type="string",
                      help="The first revision to generate logs for")

    parser.add_option("-s", "--svn-repo", dest="repo", action="store",
                      default=apacheSVN,
		      type="string",
                      help="Provide a svn repository to process")


    (options, args) = parser.parse_args()

    # Check that we have what's necessary

    notfound = re.compile('^which')
    for cmd in prereqs:
        (stdout, stdin, stderr) = popen3('which %s' % cmd)
        if (notfound.match(stderr.read())):
            parser.error ("Could not find command %s, try [apt-get|yum] install %s" %
                          (cmd, cmd))
            
    if (options.revision == None):
        parser.error("svn revision must be specified")

    print(get_commits(options.revision))
示例#34
0
文件: ya_gpg.py 项目: a25kk/stv2
 def _open_subprocess(self, *args):
     # Internal method: open a pipe to a GPG subprocess and return
     # the file objects for communicating with it.
     # cmd = self.gpg_binary + ' --yes --status-fd 2 ' + string.join(args)
     cmd = self.gpg_binary + ' --batch --yes --no-secmem-warning ' + " ".join(args)
     child_stdout, child_stdin, child_stderr = popen2.popen3(cmd)
     return child_stdout, child_stdin, child_stderr
示例#35
0
def processLoc(proj, drct, xtra=None):
	if xtra is None:
		pth = drct
		xtra = ""
	else:
		pth = os.path.join(drct, xtra)
	flist = os.listdir(pth)
	updated = inserted = 0
	for fname in flist:
		if fname.startswith("."):
			# Hidden file; skip
			continue
		fullname = os.path.join(pth, fname)
		newXtra = os.path.join(xtra, fname)
		if os.path.isdir(fullname):
			upd, ins = processLoc(proj, drct, newXtra)
			updated += upd
			inserted += ins
		else:
			if fname.endswith(".py"):
				out, inn, err = popen2.popen3("pygettext.py -a -o - %s" % fullname)
				upd, ins = processText(out.read(), proj, pth, fname, newXtra)
				updated += upd
				inserted += ins
	return (updated, inserted)
示例#36
0
def systemArgs(*args, **kwargs):
	joinStdErr = kwargs.get("joinStdErr")
	returnTuple = kwargs.get("returnTuple")
	raiseException = kwargs.get("raiseException")
	
	result = ""
	if os.name == "posix":
		if(joinStdErr):
			process = popen2.Popen4(args)
			error = None # We lose this one from returnTuple
		else:
			# only capture stderr if returnTuple 
			capturestderr = returnTuple
			process = popen2.popen3(args, capturestderr)
		error = ""
		while process.poll() == -1:
			result += process.fromchild.read()
			if(returnTuple and not joinStdErr):
				error += process.childerr.read()
		# Would it work to poll() again after it's polled out?        
		errorcode = process.poll()
		if(returnTuple):
			return (errorcode, result, error)
		else:
			if errorcode:
				raise ErrorcodeException, errorcode
	else:
		import win32process
		p = win32process.popen3("'" + "' '".split(args) + "'")
		p[1].close()
		result = p[0].read()
	return result
示例#37
0
def cmd(command):
    stdout, stdin, stderr = popen3(command)
    stdin.close()
    err = stderr.read()
    out = stdout.read()
    stdout.close()
    stderr.close()
    return out.strip()
示例#38
0
 def fetchList(self):
     (stdout, stdin,
      stderr) = popen3("%s --getfilelist '%s*.*'" % (self.bin, self.dir))
     list = stdout.readlines()
     # Useless gnokii prompt
     del list[0]
     # Get rid of whitespaces at the ends of the file name
     self.file_list = [x.strip() for x in list]
示例#39
0
 def macosx(self):
     r, w, e = popen2.popen3('xcode-select -p')
     if r.readlines() == []:
         fatal("Xcode tools are not installed. Please run xcode-select --install.")
     self.install("libtool autoconf automake")
     self.install("zlib openssl readline")
     
     self.pip_install("pipenv")
示例#40
0
def coder(lst):
    for i in lst:
        j = "mgl/" + i + ".png"
        print "processing %s -> %s" % (i, j)
        stdout, stdin, stderr = popen2.popen3("mgl2png '" + i + "' '" + j +
                                              "'")
        for i in stdout:
            pass
示例#41
0
def osra(filename):
    osra = os.path.join(os.path.realpath(os.path.dirname(sys.argv[0])),'osra.bat')
    if not os.path.isfile(osra):
        programfiles = os.environ.get("PROGRAMFILES", None)
        osra = os.path.join(programfiles, "osra", "1.3.6","osra.bat")
    stdout, stdin, stderr = popen2.popen3('"%s" -f sdf %s' % (osra, filename))  
    sdf = stdout.read()
    return sdf
示例#42
0
文件: main.py 项目: phulei/chirico
def runcmd(N, len=0):
    scmd = N
    r, w, e = popen2.popen3(scmd)
    m = r.readlines()
    e.readlines()
    r.close()
    e.close()
    w.close()
    return [os.getpid(), m]
示例#43
0
def dimention(infile):
    fin = open(infile, 'r')
    line = fin.readline()
    column = len(string.split(line, '\t')) - 1
    fin.close()

    r, w, e = popen2.popen3("wc -l " + infile)
    row = int(string.split(r.read())[0]) - 1
    return row, column
示例#44
0
 def __init__(self, cmd, capturestderr=False):
     if type(cmd) != types.StringType:
         cmd = svn.core.argv_to_command_string(cmd)
     if capturestderr:
         self.fromchild, self.tochild, self.childerr \
             = popen2.popen3(cmd, mode='b')
     else:
         self.fromchild, self.tochild = popen2.popen2(cmd, mode='b')
         self.childerr = None
示例#45
0
 def process(self, cmd):
     nwd = "%s/cyberplus/" % (os.path.dirname(__file__))
     cmd = "cd %s && ./%s" % (nwd, cmd)
     stdout, stdin, stderr = popen2.popen3(cmd)
     stdin.close()
     stderr.close()
     lines = stdout.readlines()
     stdout.close()
     return "\n".join(lines).strip()
示例#46
0
def legacy_shell_injections(input):
    """ 
    Numerous legacy APIs for shells in Python stdlib
    """
    os.system(input)
    os.popen(input)
    os.popen2(input)
    os.popen3(input)
    os.popen4(input)
    posix.system(input)
    posix.popen(input)
    popen2.popen2(input)
    popen2.popen3(input)
    popen2.popen4(input)
    popen2.Popen3(input)
    popen2.Popen4(input)
    commands.getoutput(input)
    commands.getstatusoutput(input)
示例#47
0
 def popen3(cmd, mode="t", bufsize=-1):
     """Execute the shell command 'cmd' in a sub-process.  On UNIX, 'cmd'
     may be a sequence, in which case arguments will be passed directly to
     the program without shell intervention (as with os.spawnv()).  If 'cmd'
     is a string it will be passed to the shell (as with os.system()). If
     'bufsize' is specified, it sets the buffer size for the I/O pipes.  The
     file objects (child_stdin, child_stdout, child_stderr) are returned."""
     import popen2
     stdout, stdin, stderr = popen2.popen3(cmd, bufsize)
     return stdin, stdout, stderr
示例#48
0
 def tidy_string(src):
     opts = " ".join([
         "--%s %s" % (k.replace('_', '-'), v) for k, v in TIDY_OPTS.items()
     ])
     cmd = "%s %s" % (TIDY_CMD, opts)
     (o, i, e) = popen2.popen3(cmd)
     i.write(src)
     i.flush()
     i.close()
     return o.read()
示例#49
0
def python2_specific():
    """
    These tests are mostly included to check for extra paths that can be generated if
    we can track flow into the implementation of a stdlib function, and then to another sink.
    See comment in query for more details.
    """

    files = request.args.get("files", "")
    os.popen2("ls " + files)
    os.popen3("ls " + files)
    os.popen4("ls " + files)

    platform.popen("ls " + files)

    popen2.popen2("ls " + files)
    popen2.popen3("ls " + files)
    popen2.popen4("ls " + files)
    popen2.Popen3("ls " + files)
    popen2.Popen4("ls " + files)
示例#50
0
    def __open_grid(self, filename):
        """
        Copy the file from the grid into local temporary directory and open it
        """
        name = filename.split('/')[-1]  ## assume it is LFN

        import os, tempfile

        ## build the temporary directory:
        tmpdir = tempfile.mkdtemp()

        ## create the name for the temporary file
        tmpfile = tempfile.mktemp(suffix='.root')

        ## construct the name for the temporary file in temporary
        localfile = tmpdir + os.sep + name

        try:

            ## command to copy file from the grid
            command = ' ( cd %s && dirac-dms-get-file %s ) '
            command = command % (tmpdir, filename)

            import popen2
            cout, cin, cerr = popen2.popen3(command)
            for line in cerr:
                print ' STDERR: ', line

            if not os.path.exists(localfile):
                raise NameError("Unable to get from GRID " + filename)

            ## rename the file
            os.rename(locafile, tmpfile)

            if not os.path.exists(tmpfile):
                raise NameError("Unable to get from GRID " + filename)

            self._remove = True
            self._file = ROOT.TFile(tmpfile, 'READ')

            if not self.isOK():
                raise NameError('Unable to open properly %s ' % filename)

        except:
            ## clear the temporary file in case of error
            if os.path.exists(tmpfile): os.remove(tmpfile)
            self._remove = False
            self._file = None
        finally:
            ##  clean the temporary locations
            if os.path.exists(localfile): os.remove(localfile)
            if os.path.exists(tmpdir): os.rmdir(tmpdir)

        return self.isOK()
示例#51
0
def ucon64_info(filename):
    cmd = "ucon64 --dbuh -snes \"%s\"" % filename
    r, w, e = popen2.popen3(cmd)
    err = e.readlines()
    out = r.readlines()
    r.close()
    e.close()
    w.close()
    if len(err):
        return False, err
    return out, err
示例#52
0
def compile(file_name, dire):
    s_filename = dire + file_name.replace('.c', '.s')
    args = ['gcc', '-S', '-o', s_filename, '-w', dire + file_name]
    print args
    r, w, e = popen3(' '.join(args))
    s = e.read()
    if not s.lower().find('error') == -1:
        print 'ininini'
        print s
        return "ERROR"
    return s_filename
示例#53
0
    def autot2t(self, upath):
        """自动处理t2t 到对应PyBlosxom 目录
            - upath svnlook 出来的对应更新记录
            - t2t 文件本身输出 xhtml ,cp为txt 由PyBlosxom 显示
            - 另外输出为.moin 的wiki 文件
            --target moin
        """
        #print >> self.f,"~"*7+"t2t::%s"%upath
        print >> self.f, "~" * 7 + "t2t::%s" % upath.split("/")[-1]
        #print >> self.f,"~"*7+"t2t::%s"%upath.split("/")[-1][:-4]
        t2txhtml = "%s %s" % (self.T2T, upath)
        cp2txt = "cp %s %s" % (upath[:-4] + ".xhtml", upath[:-4] + ".txt")
        t2tmoin = "%s %s %s" % (self.T2T, " --target moin ", upath)
        print >> self.f, "~" * 7 + "t2t::%s" % t2txhtml
        #print >> self.f,"~"*7+"t2t::%s"%cp2txt
        #print >> self.f,"~"*7+"t2t::%s"%t2tmoin
        print >> self.f, "~" * 7 + "t2t::%s" % os.popen(t2txhtml)
        #done = os.popen(t2txhtml)
        #print >> self.f,"~"*7+"t2t::%s"%done.read().strip()
        #os.popen(cp2txt)
        #os.popen(t2tmoin)
        try:
            r, w, e = popen2.popen3(t2txhtml)
            #print >> self.f,"~"*7+"t2t::%s"%r.read()
            print >> self.f, "~" * 7 + "t2t::%s" % e.read()
            #r, w, e = popen2.popen3(cp2txt)
            #print >> self.f,"~"*7+"t2t::%s"%r.read()
            #print >> self.f,"~"*7+"t2t::%s"%e.read()
            r, w, e = popen2.popen3(t2tmoin)
            #print >> self.f,"~"*7+"t2t::%s"%r.read()
            print >> self.f, "~" * 7 + "t2t::%s" % e.read()
            #e.readlines()
            #r.readlines()
            r.close()
            e.close()
            w.close()
        except:
            print >> self.f, "~" * 7 + "t2t::popen2.popen3() ::crash"

        #return exp
        """06-01-21 14:27:24 ******* updating...>>>>marked::pyblosxom
示例#54
0
 def start(self):
     """
     Starts local worker.
     """
     if _USE_SUBPROCESS:
         if sys.platform.startswith("win"):
             import win32process  # @UnresolvedImport
             my_env = os.environ
             my_env['PYTHONIOENCODING'] = 'latin1'
             proc = subprocess.Popen(
                 self.command,
                 shell=False,
                 stdin=subprocess.PIPE,
                 stdout=subprocess.PIPE,
                 stderr=subprocess.PIPE,
                 universal_newlines=False,
                 creationflags=win32process.CREATE_NO_WINDOW,
                 env=my_env,
             )
             self.t = pptransport.PipeTransport(proc.stdout, proc.stdin)
         else:
             if six.PY2:
                 my_env = os.environ
                 my_env['PYTHONIOENCODING'] = 'latin1'
                 proc = subprocess.Popen(
                     self.command,
                     shell=False,
                     stdin=subprocess.PIPE,
                     stdout=subprocess.PIPE,
                     stderr=subprocess.PIPE,
                     universal_newlines=False,
                     env=my_env,
                 )
                 self.t = pptransport.PipeTransport(proc.stdout, proc.stdin)
             else:
                 my_env = os.environ
                 my_env['PYTHONIOENCODING'] = 'latin1'
                 proc = subprocess.Popen(
                     self.command,
                     shell=False,
                     stdin=subprocess.PIPE,
                     stdout=subprocess.PIPE,
                     stderr=subprocess.PIPE,
                     universal_newlines=False,
                     env=my_env,
                 )
                 self.t = pptransport.PipeTransport(proc.stdout, proc.stdin)
     else:
         self.t = pptransport.PipeTransport(
             *popen2.popen3(self.command)[:2])
     self.pid = int(self.t.receive())
     self.is_free = True
     logging.info('Started new worker: %s with %s', self.pid, self.t)
示例#55
0
    def macosx(self):
        r, w, e = popen2.popen3('xcode-select -p')
        if r.readlines() == []:
            fatal(
                "Xcode tools are not installed. Please run xcode-select --install."
            )
        self.install("libtool autoconf automake llvm")
        self.install("zlib openssl readline")
        self.install("redis")
        self.install("binutils")  # into /usr/local/opt/binutils

        self.pip_install("pipenv gevent")
示例#56
0
 def _read_info(self):
     o,i,e = popen3("nvidia-smi -q -x")
     error = e.read()
     if error:
         raise Exception(error)
     _xml = etree.fromstring(o.read())
     self["driver"] = _xml.find("driver_version").text
     gpus = _xml.findall("gpu")
     self["ngpus"] = len(gpus)
     self["types"]  = [i.find("product_name").text for i in gpus]
     self["serials"] = [i.find("serial").text for i in gpus]
     self._xml = _xml
示例#57
0
    def getTextProductFromDB(self, productID):
        cmd = "textdb -r " + productID

        (stdout, stdin, stderr) = popen2.popen3(cmd)

        textList = []
        line = stdout.readline()
        textList.append(line)
        while line != "":
            line = stdout.readline()
            textList.append(line)
        return textList
示例#58
0
    def run_cmd_capture(self, cmd):
        (cout, cin, cerr) = popen2.popen3(cmd)

        cin.close()

        output = cout.readlines()
        cout.close()

        errors = cerr.readlines()
        cerr.close()

        return (''.join(output), ''.join(errors))