当前位置: 首页>>代码示例>>Python>>正文


Python Popen.rstrip方法代码示例

本文整理汇总了Python中subprocess.Popen.rstrip方法的典型用法代码示例。如果您正苦于以下问题:Python Popen.rstrip方法的具体用法?Python Popen.rstrip怎么用?Python Popen.rstrip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在subprocess.Popen的用法示例。


在下文中一共展示了Popen.rstrip方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: analyze_ensemble

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rstrip [as 别名]
def analyze_ensemble(seq,filename,sample_size=100):
    
    chdir(project_dir)

    system("echo '>" + filename + "\n" + str(seq) + "' > " + filename + ".fa")                 

    output_ss = Popen("./3rdParty/vienna/RNAsubopt -d2 -noLP -s -p "+str(sample_size)+" < " + filename + ".fa | tail -n "+str(sample_size), stdout=PIPE, shell=True).stdout.read()
        
    l = output_ss.rstrip().split('\n')
    ens_st = []
    
    string_aux = ""
    
    for st in l:
        string_aux += str(seq) + "\n" + str(st) + "\n"
        
    system("echo '" + str(string_aux) + "' > " + filename + ".st")
    output_ss = Popen("./3rdParty/vienna/RNAeval -d2 < " + filename + ".st | perl -lne 'm/.* \((.*)\)$// print $1'", stdout=PIPE, shell=True).stdout.read().rstrip()
    ens_st = map(lambda x: float(x), output_ss.rstrip().split('\n')[2:])

    data = {}
    data['StructureEnsembleSample'] = ens_st
    data['StructureEnsembleSampleMean'] = average(ens_st)
    data['StructureEnsembleSampleSD'] = stddev(ens_st)
    
    system("rm %s*" % filename)
    
    # remove tmp files
    #system("rm %s*" % filename)
    #system("mv " + filename + "* tmp/unafold_files/")             
 
    return data
开发者ID:alexechu,项目名称:d-tailor,代码行数:34,代码来源:Functions.py

示例2: testRemoveDuplicates

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rstrip [as 别名]
 def testRemoveDuplicates(self):
     TestConversionTools.sample.bam = BamFile.BamFile(TestConversionTools.testPool, TestConversionTools.sample, TestConversionTools.bamFile)
     self.convTools.removeDuplicates(TestConversionTools.sample)
     self.convTools.convertToBam(TestConversionTools.sample)
     self.assertTrue(os.path.exists(TestConversionTools.expBamOutFile), "output file not created...")
     output ,error = Popen(Program.config.getPath("samtools") + " view -h " + TestConversionTools.expBamOutFile +" | wc -l", shell=True, stdout=PIPE, stderr=PIPE).communicate()
     self.assertEqual(output.rstrip(), "1266", "number of lines: " +  output.rstrip() + " is not " + str(1266))
开发者ID:JJacobi13,项目名称:VLPB,代码行数:9,代码来源:TestConversionTools.py

示例3: get_selection

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rstrip [as 别名]
def get_selection(aps, vpns, gsms, others):
    """Combine the arg lists and send to dmenu for selection.
    Also executes the associated action.

    Args: args - aps: list of Actions
                 vpns: list of Actions
                 gsms: list of Actions
                 others: list of Actions
    """

    conf = configparser.ConfigParser()
    conf.read(expanduser("~/.config/networkmanager-dmenu/config.ini"))

    try:
        rofi_highlight = conf.getboolean('dmenu', 'rofi_highlight')
    except (configparser.NoOptionError, configparser.NoSectionError):
        rofi_highlight = False

    inp = []
    empty_action = [Action('', None)]
    all_actions = []
    all_actions += aps + empty_action if aps else []
    all_actions += vpns + empty_action if vpns else []
    all_actions += gsms + empty_action if gsms else []
    all_actions += others

    if rofi_highlight is True:
        inp = [str(action) for action in all_actions]
    else:
        inp = [('** ' if action.is_active else '   ') + str(action)
               for action in all_actions]
    active_lines = [index for index, action in enumerate(all_actions)
                    if action.is_active]

    inp_bytes = "\n".join([i for i in inp]).encode(ENC)
    command = dmenu_cmd(len(inp), active_lines=active_lines)
    sel = Popen(command, stdin=PIPE, stdout=PIPE,
                env=ENV).communicate(input=inp_bytes)[0].decode(ENC)

    if not sel.rstrip():
        sys.exit()

    if rofi_highlight is False:
        action = [i for i in aps + vpns + gsms + others
                  if ((str(i).strip() == str(sel.strip())
                       and not i.is_active) or
                      ('** ' + str(i) == str(sel.rstrip('\n'))
                       and i.is_active))]
    else:
        action = [i for i in aps + vpns + gsms + others
                  if str(i).strip() == sel.strip()]
    assert len(action) == 1, \
            u"Selection was ambiguous: '{}'".format(str(sel.strip()))
    return action[0]
开发者ID:Cypher1,项目名称:Castle,代码行数:56,代码来源:wifi.py

示例4: rename_file

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rstrip [as 别名]
def rename_file (video_file_name_extn, extn):

    # Extract the meta data into a temporary file "meta.txt"
    Popen ('ffmpeg -i \"' + video_file_name_extn + '\" -f ffmetadata ' + ' meta.txt' , shell=True, stdout=PIPE).stdout.read()

    # Extract the show name
    show_name = Popen ('grep show= meta.txt' , shell=True, stdout=PIPE).stdout.read()
    
    # Do not rename if it is not a show
    if (show_name == ''):
        system ('rm -rf meta.txt')
        return (video_file_name_extn)
    show_name = show_name.replace ('show=', '')
    show_name = show_name.rstrip()

    # Extract the season number
    season = Popen ('grep season_number meta.txt' , shell=True, stdout=PIPE).stdout.read()
    season = season.replace ('season_number=', '')
    season = season.rstrip()

    # Extract the episode number
    episode_sort = Popen ('grep episode_sort meta.txt' , shell=True, stdout=PIPE).stdout.read()
    episode_sort = episode_sort.replace ('episode_sort=', '')
    episode_sort = episode_sort.rstrip()

    # Extract the episode title
    episode_name = Popen ('grep title= meta.txt' , shell=True, stdout=PIPE).stdout.read()
    episode_name = episode_name.replace ('title=', '')
    episode_name = episode_name.rstrip()
    
    # Delete temporary "meta.txt" file.
    system ('rm -rf meta.txt')

    # Construct the complete file name
    final_episode_name = ''
    if (int(season)<10):
        final_episode_name = final_episode_name + show_name + ' S0' + season
    else:
        final_episode_name = final_episode_name + show_name + ' S'  + season


    if (int(episode_sort) < 10):
        final_episode_name = final_episode_name + 'E0' + episode_sort
    else:
        final_episode_name = final_episode_name + 'E' + episode_sort

    final_episode_name = final_episode_name + ' ' + episode_name + extn

    # Return the constructed file name
    return final_episode_name
开发者ID:avdd80,项目名称:rename,代码行数:52,代码来源:rename.py

示例5: get_revision

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rstrip [as 别名]
    def get_revision(self, path_to_repository):
        if path_to_repository.startswith("~"):
            home_dir = os.path.expanduser("~")
            path_to_repository = home_dir + path_to_repository[1:]

        revision =  Popen("git rev-parse HEAD", cwd=path_to_repository, stdout=PIPE, shell=True).stdout.read()
        return revision.rstrip()
开发者ID:mfrey,项目名称:baltimore,代码行数:9,代码来源:git.py

示例6: _retrWacomDeviceNames

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rstrip [as 别名]
	def _retrWacomDeviceNames(self):
		"""
		Get the details of all connected Wacom Devices by using the "xsetwacom" command.
		"""
		logging.info("retrieving Devices")
		wacomDevices = []
		try:
			output = Popen(["xsetwacom", "--list", "devices"], stdout=PIPE).communicate()[0]
		except FileNotFoundError:
			logging.error("'xsetwacom' command not found. Please install and try again")
			sys.exit(-1)
		if len(output) == 0:
			return

		for line in output.rstrip().split(b'\n'):
			wacomDevices.append(line.split(b'\t'))

		for entry in wacomDevices:
			if 'STYLUS' in entry[2].decode("utf-8"):
				logging.info("stylus device found...")
				self._stylusDev = Stylus(entry[0].rstrip().decode("UTF-8"))
				self.devices.append(self._stylusDev)
			elif 'ERASER' in entry[2].decode("utf-8"):
				logging.info("eraser device found...")
				self._eraserDev = Eraser(entry[0].rstrip().decode("UTF-8"))
				self.devices.append(self._eraserDev)
			elif 'TOUCH' in entry[2].decode("utf-8"):
				logging.info("touch device found...")
				self._touchDev = Touch(entry[0].rstrip().decode("UTF-8"))
				self.devices.append(self._touchDev)
开发者ID:FelixHaller,项目名称:hinge,代码行数:32,代码来源:System.py

示例7: parse

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rstrip [as 别名]
    def parse (self, line, output = True):
        if (output == True):
            if len (line) > 1 and line[0] != '#':
                m = self.atRecordRegex.match(line)
                if m != None:
                    # Time
                    time = m.group('time')

                    # FreeBSD:
                    # We are ignoring timezone and hope everything works
                    # out in the end.

                    # Date
                    day = m.group('day')
                    month = m.group ('month')

                    for monthname in self.months:
                        month = month.replace (monthname, self.months[monthname])

                    if int (day) < 10:
                        day = "0" + day
                    if int (month) < 10:
                        month = "0" + month

                    date = day + "." + month + "." + m.groups ()[5]

                    job_id = m.group ('jobid')
                    class_id = m.group ('class')
                    user = m.group ('user')

                    success, title, desc, manual_poscorrect, output, display, stdlocale = self.get_job_data (int (job_id))
                    # manual_poscorrect is only used during preparation of script

                    execute = config.getAtbin() + " -c " + job_id
                    # read lines and detect starter
                    script = Popen(execute, shell = True, env = self.at_env, stdout = PIPE).stdout.read()
                    script,  dangerous = self.__prepare_script__ (script, manual_poscorrect, output, display, stdlocale)

                    #removing ending newlines, but keep one
                    #if a date in the past is selected the record is removed by at, this creates an error, and generally if the script is of zero length
                    # TODO: complain about it as well
                    script = script.rstrip()

                    return job_id, date, time, class_id, user, script, title, dangerous, output

        elif (output == False):
            if len (line) > 1 and line[0] != '#':
                m = self.atRecordRegexAdd.search(line)
                #print "Parsing line: " + line
                if m != None:
                    #print "Parse successfull, groups: "
                    #print m.groups()
                    job_id = m.group('jobid')
                    return int(job_id)
                else:
                    return False

        return False
开发者ID:GNOME,项目名称:gnome-schedule,代码行数:60,代码来源:at.py

示例8: spawn_tars

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rstrip [as 别名]
def spawn_tars(name, x=0, y=0):
	try:
		tars_root = Popen(['rospack', 'find', 'tars_world'], stdout=PIPE).stdout.read()
		tars_root = tars_root.rstrip()
	except Exception as er:
		return
	tars_file = tars_root+'/urdf/tars.xacro'
	controllers = ['joint1_position_controller', 'joint2_position_controller', 'joint3_position_controller']
	return gazebo_spawn_robot(tars_file, name, controllers, x, y)
开发者ID:dbrody,项目名称:tars_robot_sim,代码行数:11,代码来源:level_helper.py

示例9: check_user_group

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rstrip [as 别名]
def check_user_group(username, group):
    try:
        user_groups = Popen(["groups", username],
                            stdout=PIPE).communicate()[0]
        user_groups = user_groups.rstrip("\n").replace(" :", "").split(" ")

        if group in user_groups:
            return True
        else:
            return False

    except KeyError:
        return False
开发者ID:bluecmd,项目名称:ops-restd,代码行数:15,代码来源:user_utils.py

示例10: qsub

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rstrip [as 别名]
def qsub(command, job_name=None, stdout=None, stderr=None, depend=None, n_cores=None):
	"""
	depend could be either a string or a list (or tuple, etc.)
	"""
	args = ['qsub']
	if n_cores:
		args.extend(['-pe','generic',"%d"%n_cores])
	if job_name:
		args.extend(['-N', job_name])
	if stderr:
		args.extend(['-e', stderr])
	if stdout:
		args.extend(['-o', stdout])
	if depend:
		# in python3, use isinstance(depend, str) instead.
		if not isinstance(depend, basestring):
			depend = ','.join(depend)
		args.extend(['-hold_jid', depend])
	out = Popen(args, stdin=PIPE, stdout=PIPE).communicate(command + '\n')[0]
	print out.rstrip()
	job_id = out.split()[2]
	return job_id
开发者ID:giffy1,项目名称:MIL,代码行数:24,代码来源:qsub.py

示例11: delete_connection

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rstrip [as 别名]
def delete_connection():
    """Display list of NM connections and delete the selected one

    """
    conn_acts = [Action(i.get_id(), i.delete) for i in CONNS]
    conn_names = "\n".join([str(i) for i in conn_acts]).encode(ENC)
    sel = Popen(dmenu_cmd(len(conn_acts), "CHOOSE CONNECTION TO DELETE:"),
                stdin=PIPE,
                stdout=PIPE,
                env=ENV).communicate(input=conn_names)[0].decode(ENC)
    if not sel.strip():
        sys.exit()
    action = [i for i in conn_acts if str(i) == sel.rstrip("\n")]
    assert len(action) == 1, u"Selection was ambiguous: {}".format(str(sel))
    action[0]()
开发者ID:Cypher1,项目名称:Castle,代码行数:17,代码来源:wifi.py

示例12: blast_vs_db

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rstrip [as 别名]
def blast_vs_db(query, db):
    """
    Blast `subject` (fasta file) against `db` (blast db). 
    Returns list of lists, each `[qseqid, sseqid, pident, length]`   
    """
    out = Popen(
        ['blastn',
        '-query', query,
        '-db', db,
        '-outfmt', '10 qseqid sseqid pident length',
        ], stdout=PIPE
    ).communicate()[0]
    if out:
        result = re.split(r'[,\n]', out.rstrip())
        return [result[i:i+4] for i in range(len(result))[0::4]]
开发者ID:gitter-badger,项目名称:kvasir,代码行数:17,代码来源:KvasirBlast.py

示例13: blast_vs_fasta

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rstrip [as 别名]
def blast_vs_fasta(query, subject):
    """
    Blast `query` against `subject`. Both must be paths to fasta file
    Returns list of lists, each `[sseqid, qseqid, pident, length]`   
    """
    out = Popen(
        ['blastn',
        '-query', query,
        '-subject', subject,
        '-outfmt', '10 sseqid qseqid pident length',
        ], stdout=PIPE
    ).communicate()[0]
    if out:
        result = re.split(r'[,\n]', out.rstrip())[0]
        return [result[i:i+4] for i in range(len(result))[0::4]]
开发者ID:gitter-badger,项目名称:kvasir,代码行数:17,代码来源:KvasirBlast.py

示例14: get_ids

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rstrip [as 别名]
 def get_ids(self):
     """
     Get all ids of the namespaces
     :return: The list of namespace ids, e.g., ['red', 'blue']
     """
     run_cmd = '%s list' % self.ns_cmd
     spaces, err = Popen(run_cmd, stdout=PIPE, stderr=PIPE,
                         shell=True).communicate()
     if err:
         error("Failed to run %s, err=%s\n" % (run_cmd, err))
         return None
     if not spaces:  # spaces == ''
         return None
     ns_list = spaces.rstrip('\n').split('\n')
     ns_list.sort()
     return ns_list
开发者ID:li525628,项目名称:easyOVS,代码行数:18,代码来源:namespaces.py

示例15: _readSettings

# 需要导入模块: from subprocess import Popen [as 别名]
# 或者: from subprocess.Popen import rstrip [as 别名]
	def _readSettings(self):
		"""
		Reads the current settings of the screen device.
		Information is obtained with the help of the "xrandr" command.

		"""
		output = Popen(["xrandr", "--current"], stdout=PIPE).communicate()[0]
		devices_raw = output.rstrip().split(b'\n')
		for line in devices_raw:
			#take everything before the braces, clean it up and split on spaces
			line = line.split(b'(')[0].rstrip().split(b' ')
			if line[0] == b'LVDS1':
				self._name = line[0]
				if line[-1].decode("utf-8") in self.rotModes:
					self._orientation = line[-1]
				else:
					self._orientation = b'normal'
开发者ID:FelixHaller,项目名称:hinge,代码行数:19,代码来源:XDevice.py


注:本文中的subprocess.Popen.rstrip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。