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


Python shlex.shlex_split函数代码示例

本文整理汇总了Python中shlex.shlex_split函数的典型用法代码示例。如果您正苦于以下问题:Python shlex_split函数的具体用法?Python shlex_split怎么用?Python shlex_split使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: create

    def create(self, part, opath, ipath):
        try:
            if not opath.endswith('.ubi'):
                opath = '%s.ubi' % opath
                
            if not os.path.isdir(ipath):
                self.error('Input path is not a directory.')

            if part.lower() == 'erootfs':
                ini_file = os.path.join(self._app_path, 'firmware/ubi_cfg/%serootfs.ini' % self._ubi_version)
            elif part.lower() == 'bulk':
                ini_file = os.path.join(self._app_path, 'firmware/ubi_cfg/%sbulk.ini' % self._ubi_version)
            else:
                self.error('Partion must be erootfs, or bulk.')

            mkfs = '-c %s -m %s -e %s -r %s' % (self._params['max_leb_cnt'],
                                                self._params['min_io_size'],
                                                self._params['leb_size'],
                                                ipath)

            ubinz = '-o %s -p %s -m %s -s %s -O %s %s' % (opath,
                                                          self._params['peb_size'],
                                                          self._params['min_io_size'],
                                                          self._params['sub_page_size'],
                                                          self._params['vid_hdr_offset'],
                                                          ini_file)

            cmd_mkubi = shlex_split('sudo /usr/sbin/mkfs.ubifs %s temp.ubifs' % (mkfs))        
            cmd_ubinize = shlex_split('sudo /usr/sbin/ubinize  %s' % (ubinz))
            cmd_rmimg = shlex_split('sudo rm temp.ubifs')
            cmd_chmod = shlex_split('sudo chmod 777 %s' % opath)
            cmds = [cmd_mkubi, cmd_ubinize, cmd_rmimg, cmd_chmod]
            self.popen_arr(cmds)
        except Exception, e:
            self.error(e)
开发者ID:Gargash,项目名称:OpenLFConnect,代码行数:35,代码来源:images.py

示例2: changeMusicVolume

def changeMusicVolume(change, steps=0):
    "Changes volume according to string; can be either absolute ('40') or change ('2%-')."
    if steps == 0:
        call(shlex_split("amixer set Master " + str(change)))  # CHANGEME somehow, if amixer doesn't work
    else:
        cur = get_state()
        interval = 1. / steps
        for a in drange(cur, int(change), float(int(change) - cur) / steps):
            call(shlex_split("amixer set Master " + str(a)))
            sleep(interval)
开发者ID:hsingh23,项目名称:Music-Fiddler-2,代码行数:10,代码来源:Music-Fiddler.py

示例3: _get_terminal_size_tput

def _get_terminal_size_tput():
    # get terminal width
    # src: http://stackoverflow.com/questions/263890/how-do-i-find-the-width-height-of-a-terminal-window
    try:
        cols = int(subprocess_check_call(shlex_split('tput cols')))
        rows = int(subprocess_check_call(shlex_split('tput lines')))

        return (cols, rows)
    except:
        pass
开发者ID:billyprice1,项目名称:dump-scraper,代码行数:10,代码来源:terminalsize.py

示例4: umount

    def umount(self):
        try:
            cmd_umount = shlex_split('sudo /bin/umount %s' % self._mount)
            cmd_rmmod = shlex_split("sudo /sbin/rmmod jffs2 mtdblock mtdram")
            cmds = [cmd_umount, cmd_rmmod]
            self.popen_arr(cmds)

            if os.path.exists(self._mount):
                self.popen(shlex_split('sudo rmdir %s' % self._mount))
        except Exception, e:
            self.error(e)
开发者ID:Gargash,项目名称:OpenLFConnect,代码行数:11,代码来源:images.py

示例5: registry_information

    def registry_information(self):
        """
        actually list all available databases

        "name" filed in retrieved information could be used to retrieve available datasets.

        Example:

<MartRegistry>
  <MartURLLocation database="ensembl_mart_65" default="1" displayName="ENSEMBL GENES 65 (SANGER UK)" host="www.biomart.org" includeDatasets="" martUser="" name="ensembl" path="/biomart/martservice" port="80" serverVirtualSchema="default" visible="1" />
  <MartURLLocation database="snp_mart_65" default="0" displayName="ENSEMBL VARIATION 65 (SANGER UK)" host="www.biomart.org" includeDatasets="" martUser="" name="snp" path="/biomart/martservice" port="80" serverVirtualSchema="default" visible="1" />
  <MartURLLocation database="functional_genomics_mart_65" default="0" displayName="ENSEMBL REGULATION 65 (SANGER UK)" host="www.biomart.org" includeDatasets="" martUser="" name="functional_genomics" path="/biomart/martservice" port="80" serverVirtualSchema="default" visible="1" />
  ...
</MartRegistry>
        """

        params_dict = {"type":"registry"}

        status, reason, data = self.easy_response(params_dict, echo=False)

        # parse the output to make it more readable
        databases = []
        for line in data.strip().split('\n'):
            ln = shlex_split(line)
            ln_dict = dict(item.split('=') for item in ln if '=' in item)
            if 'name' in ln_dict and 'displayName' in ln_dict:
                databases.append(OrderedDict(biomart=ln_dict['name'], version=ln_dict['displayName']))
        name_max_len = max(len(d['biomart']) for d in databases)
        version_max_len = max(len(d['version']) for d in databases)

        print "".ljust(5), 'biomart'.rjust(name_max_len+1), 'version'.rjust(version_max_len+1)
        for i, d in enumerate(databases):
            print str(i+1).ljust(5), d['biomart'].rjust(name_max_len+1), d['version'].rjust(version_max_len+1)

        return databases
开发者ID:Jellycat0000,项目名称:pyinfor,代码行数:35,代码来源:biomart.py

示例6: receive

    def receive(self, type='small', dblchk=0):
        try:
            if type == 'small':
                request_len = self._request_small
                trans_len = '01'
                lba = '20'
            else:
                request_len = self._request_large
                trans_len = '14'
                lba = '40' 
    
            scsi_cmd = '%s %s -b -r %s -n 28 00 00 00 00 %s 00 00 %s 00' % (self._sg_raw, self._conn_iface.device_id, request_len, lba, trans_len)
            scsi_cmd = shlex_split(scsi_cmd)
            p = Popen(scsi_cmd, bufsize=0, stdout=PIPE, stderr=PIPE)
            line = p.stdout.read()

            if line == '':
                if dblchk < 10:
                    sleep(1)
                    dblchk += 1
                    line = self.receive(type, dblchk)
            if '102 BUSY' in line:
                sleep(1)
                line = self.receive(type, dblchk)

            if line:
                return line
            else:
                return False
        except Exception, e:
            self.error('Receiving error: %s' % e)
开发者ID:Gargash,项目名称:OpenLFConnect,代码行数:31,代码来源:mass_storage.py

示例7: _blind

def _blind(dir_path):
    # First strip additional arguments
    subset_cmd = ('./subset.py -s core -m '
            '-a Site,CSite,Sidechain,Contextgene {}'
            ).format(' '.join(_find(dir_path, '.*\.a2')))
    subset_main(shlex_split(subset_cmd))

    # We need to rename the new core files
    for a2_core_file_path in _find(dir_path, '.*\.a2.core'):
        a2_file_path = a2_core_file_path[:-5]
        assert isfile(a2_file_path)
        move(a2_core_file_path, a2_file_path)

    # Then negation and speculations
    for a2_file_path in _find(dir_path, '.*\.a2'):
        with open(a2_file_path, 'r') as a1_file:
            a1_data = a1_file.read().split('\n')

        # Write the annotations again without modifiers
        with open(a2_file_path, 'w') as a1_file:
            lines = []
            for line in a1_data:
                line_m = NESP_REGEX.match(line)
                if line_m is None:
                    lines.append(line)
            a1_file.write('\n'.join(lines))
开发者ID:spyysalo,项目名称:bionlp_st_2011_supporting,代码行数:26,代码来源:enrich.py

示例8: tags

    def tags(self, tag_names):
        '''Get tags details from repository

        To know how to parse, to see the output of following command

        To get which branches a commit belongs to.
        git --git-dir=/path/to/repo/.git branch --contains commit_hash

        :return: sequence of GitTag
        '''
        git_cat_file = 'git --git-dir={0} cat-file -p `git --git-dir={0} rev-parse {1}`'
        git_branch = 'git --git-dir={0} branch --contains {1}'

        for tag_name in tag_names:
            git_cmd = git_cat_file.format(self.git_dir, tag_name)
            proc, stdout, stderr = git(git_cmd, shell=True)

            try:
                tag = GitTag.parse(stdout)
            except InvalidTagError as error:
                error.data = tag_name
                yield error
            else:
                git_cmd = git_branch.format(self.git_dir, tag.commit_hash)
                proc, stdout, stderr = git(shlex_split(git_cmd))
                for line in sbuffer_iterator(stdout):
                    tag.add_branch_name(line.strip('* \r\n'))

                yield tag
开发者ID:yanhuitiyubu,项目名称:gitView,代码行数:29,代码来源:git.py

示例9: call_sg_raw

 def call_sg_raw(self, cmd, arg='None', buf_len=0):
     try:
         
         if len(self._settings[arg]) == 0:
             self.error('Bad settings value')                    
         elif len(self._cdb_cmds[cmd]) == 0:
             self.error('Bad command')
             
         if buf_len:
             buf_len = '-r%s -b' % buf_len
         else:
             buf_len = ''
             
         cmdl = '%s %s %s %s %s 00 00 00 00 00 00 00 00' % (self._sg_raw, buf_len, self._mount_config.device_id, self._cdb_cmds[cmd], self._settings[arg])
         cmd = shlex_split(cmdl)
         p = Popen(cmd, stdout=PIPE, stderr=PIPE)
         err = p.stderr.read()
         
         if not 'Good' in err:
             if arg != 'None':
                 return False
             else:
                 self.error('SCSI error.')
             
         if arg != 'None':
             sleep(1)
             return p.stdout.read()      
     except Exception, e:
         self.error(e)
开发者ID:Gargash,项目名称:OpenLFConnect,代码行数:29,代码来源:didj.py

示例10: test_nonexisting_file

def test_nonexisting_file(tmpdir):
    tmpdir.chdir()
    tmpdir.join("mysourcecode.txt").write("1.2.3")
    with pytest.raises(IOError):
        main(shlex_split("patch --current-version 1.2.3 mysourcecode.txt doesnotexist2.txt"))

    # first file is unchanged because second didn't exist
    assert '1.2.3' == tmpdir.join("mysourcecode.txt").read()
开发者ID:technodeep,项目名称:bumpversion,代码行数:8,代码来源:tests.py

示例11: _extract

def _extract(arch_path, dir_path):
    tar_cmd = 'tar -x -z -f {} -C {}'.format(arch_path, dir_path)
    tar_p = Popen(shlex_split(tar_cmd), stderr=PIPE)
    tar_p.wait()
    tar_p_stderr = tar_p.stderr.read()
    if tar_p_stderr:
        print >> stderr, tar_p_stderr
        assert False, 'tar exited with an error'
开发者ID:spyysalo,项目名称:bionlp_st_2011_supporting,代码行数:8,代码来源:enrich.py

示例12: _parse_import

 def _parse_import(self, token):
     parts = shlex_split(token.body)
     fn = parts[0]
     if len(parts) > 1:
         assert parts[1] == 'as'
         return ir.ImportNode(fn, parts[2])
     else:
         return ir.ImportNode(fn)
开发者ID:nandoflorestan,项目名称:kajiki,代码行数:8,代码来源:text.py

示例13: from_terminal

def from_terminal(subject):
    from subprocess import run as run_bash
    from shlex import split as shlex_split

    for command in bash_commands[subject]:
        print('> EXECUTING:', command)
        run_bash(shlex_split(command), timeout=None, check=True)
    return True
开发者ID:adi-,项目名称:django-markdownx,代码行数:8,代码来源:dev.py

示例14: clone

    def clone(self, repo_url, quiet=True):
        '''Clone remote repository to local working directory'''
        if os.path.exists(self.repo_dir):
            raise OSError('Repo {0} already exists.'.format(self.repo_dir))

        git_cmd = 'git clone {0} {1} {2}'.format('-q' if quiet else '',
                                                 repo_url,
                                                 self.repo_dir)
        git(shlex_split(git_cmd))
开发者ID:yanhuitiyubu,项目名称:gitView,代码行数:9,代码来源:git.py

示例15: pipeopen

def pipeopen(command, allowfork=False):
    args = shlex_split(str(command))

    preexec_fn = fastclose
    if allowfork:
        preexec_fn = lambda : (fastclose(), unblock_sigchld())

    return Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE,
        close_fds=False, preexec_fn=preexec_fn)
开发者ID:650elx,项目名称:middleware,代码行数:9,代码来源:pipesubr.py


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