• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utils.cexec函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: scan_device_port

    def scan_device_port(self, sync_value, uuid):
        port = 0

        for i in range(0, 10):
            cexec([self._adb, 'forward', 'tcp:{}'.format(PORT_START + i), 'tcp:{}'.format(PORT_START + i)],
                  callback=None)
            url = 'http://127.0.0.1:{}/checkSync?sync={}&uuid={}'.format(PORT_START + i, sync_value, uuid)
            result, err, code = curl(url)
            if code == 0 and result is not None:
                result = int(result)
                self.debug('server result is {}'.format(result))
                if result == 0:
                    self.debug('check sync value failed, maybe you need a clean build.')
                    from exceptions import CheckSyncStateException
                    raise CheckSyncStateException('check sync value failed, maybe you need a clean build.',
                                                  'NO CAUSE')
                elif result == -1:
                    continue
                else:
                    port = PORT_START + i
                    break

        for i in range(0, 10):
            if (PORT_START + i) != port:
                cexec([self._adb, 'forward', '--remove', 'tcp:{}'.format(PORT_START + i)], callback=None)

        return port
开发者ID:fenglincanyi,项目名称:Study,代码行数:27,代码来源:sync_client.py


示例2: scan_device_port

    def scan_device_port(self):
        port = 0
        apktime_path = self._get_apktime_path()
        self.debug("apktime path: " + apktime_path)
        sync_value = get_sync_value(apktime_path, self._cache_dir)
        self.debug('your local sync value is: {}'.format(sync_value))
        uuid = get_apk_created_ticket(apktime_path)
        self.debug('your local uuid value is: {}'.format(uuid))

        for i in range(0, 10):
            cexec([self._adb, 'forward', 'tcp:{}'.format(41128 + i), 'tcp:{}'.format(41128 + i)], callback=None)
            url = 'http://127.0.0.1:{}/checkSync?sync={}&uuid={}'.format(41128 + i, sync_value, uuid)
            result, err, code = curl(url)
            if code == 0 and result is not None:
                result = int(result)
                self.debug('server result is {}'.format(result))
                if result == 0:
                    self.debug('check sync value failed, maybe you need a clean build.')
                    from exceptions import CheckSyncStateException
                    raise CheckSyncStateException('check sync value failed, maybe you need a clean build.',
                                                  'NO CAUSE')
                elif result == -1:
                    continue
                else:
                    port = 41128 + i
                    break

        for i in range(0, 10):
            if (41128 + i) != port:
                cexec([self._adb, 'forward', '--remove', 'tcp:{}'.format(41128 + i)], callback=None)

        return port
开发者ID:568,项目名称:ThirdPlugin,代码行数:32,代码来源:sync_client.py


示例3: wake_up

    def wake_up(self, need_protection=False):
        package = self._config['package']
        if 'debug_package' in self._config:
            package = self._config['debug_package']

        wake_up_args = [self._adb, 'shell', 'am', 'startservice', '-n',
                        '{}/{}'.format(package, 'com.antfortune.freeline.FreelineService')]
        if not need_protection:
            wake_up_args.extend(['-e', 'wakeup', 'marker'])
        self.debug('wake up Service: {}'.format(' '.join(wake_up_args)))
        cexec(wake_up_args, callback=None)
开发者ID:568,项目名称:ThirdPlugin,代码行数:11,代码来源:sync_client.py


示例4: connect_device

    def connect_device(self):
        self.debug('start to connect device...')
        if not self.check_installation():
            return
        sync_value, uuid = self._get_check_values()
        self.scan_to_get_port(sync_value, uuid)

        if self._port == 0:
            self.check_device_connection()
            commands = [self._adb, 'uninstall', self._config['debug_package']]
            cexec(commands, callback=None)
        self.debug('find device port: {}'.format(self._port))
开发者ID:alibaba,项目名称:freeline,代码行数:12,代码来源:sync_client.py


示例5: _install_apk

    def _install_apk(self):
        if self._adb:
            if not os.path.exists(self._apk_path):
                raise FreelineException('apk not found.', 'apk path: {}, not exists.'.format(self._apk_path))

            install_args = [self._adb, 'install', '-r', self._apk_path]
            self.debug('start to install apk to device: {}'.format(' '.join(install_args)))
            output, err, code = cexec(install_args, callback=None)

            if 'Failure' in output:
                self.debug('install apk failed, start to retry.')
                output, err, code = cexec(install_args, callback=None)
                if 'Failure' in output:
                    raise FreelineException('install apk to device failed.', '{}\n{}'.format(output, err))
开发者ID:Ryanst,项目名称:AndroidDemo,代码行数:14,代码来源:android_tools.py


示例6: run_desugar_task

    def run_desugar_task(self):
        self.debug('========= desugar task ========')
        javaargs = [Builder.get_java(self._config)]
        arguments = ['-jar', Builder.get_desugar()]
        patch_classes_cache_dir = self._finder.get_patch_classes_cache_dir()

        arguments.append('--input')
        arguments.append(patch_classes_cache_dir)
        arguments.append('--output')
        arguments.append(patch_classes_cache_dir)

        # bootclasspath
        arguments.append('--bootclasspath_entry')
        arguments.append(os.path.join(self._config['compile_sdk_directory'], 'android.jar'))

        # classpath
        for path in self._classpaths:
            arguments.append('--classpath_entry')
            arguments.append(path)

        javaargs.extend(arguments)

        self.debug('java exec: ' + ' '.join(javaargs))
        output, err, code = cexec(javaargs, callback=None)

        if code != 0:
            raise FreelineException('desugar failed.', '{}\n{}'.format(output, err))
开发者ID:alibaba,项目名称:freeline,代码行数:27,代码来源:gradle_inc_build.py


示例7: _check_connection

    def _check_connection(self):
        self.debug('check device\' connection...')
        commands = [self._adb, 'devices']
        output, err, code = cexec(commands, callback=None)
        if code == 0:
            devices = output.strip().split('\n')
            length = len(devices)
            from exceptions import UsbConnectionException
            if length < 2:
                raise UsbConnectionException('No device\'s connection found',
                                             '\tUse `adb devices` to check your device connection')
            if length > 2:
                raise UsbConnectionException('More than 1 device connect',
                                             '\tOnly 1 device allowed, '
                                             'use `adb devices` to check your devices\' connection')
            for content in devices:
                if content.find('offline') <> -1:
                    raise UsbConnectionException('Device is connected but offline',
                                                '\tPlease replug in device')

                if content.find('unauthorized') <> -1:
                    raise UsbConnectionException('Device is connected but unauthorized',
                                                '\tReplug in device and accept authorization as usual')

                if not (content.find('device') > -1):
                    raise UsbConnectionException('Device is connected but unknown status',
                                                '\tPlease replug in device')
开发者ID:alibaba,项目名称:freeline,代码行数:27,代码来源:android_tools.py


示例8: execute

 def execute(self):
     command = '{} -q checkBeforeCleanBuild'.format(get_gradle_executable(self._config))
     output, err, code = cexec(command.split(' '), callback=None)
     if code != 0:
         from exceptions import FreelineException
         raise FreelineException('freeline failed when read project info with script: {}'.format(command),
                                 '{}\n{}'.format(output, err))
开发者ID:alibaba,项目名称:freeline,代码行数:7,代码来源:gradle_clean_build.py


示例9: run_retrolambda

    def run_retrolambda(self):
        if self._is_retrolambda_enabled:
            lambda_config = self._config['retrolambda'][self._name]
            target_dir = self._finder.get_patch_classes_cache_dir()
            jar_args = [Builder.get_java(self._config),
                        '-Dretrolambda.inputDir={}'.format(target_dir),
                        '-Dretrolambda.outputDir={}'.format(target_dir)]

            if lambda_config['supportIncludeFiles']:
                include_files = []
                classes = []
                for dirpath, dirnames, files in os.walk(target_dir):
                    for fn in files:
                        if fn.endswith('.class'):
                            classes.append(os.path.relpath(os.path.join(dirpath, fn), target_dir))

                src_dirs = self._config['project_source_sets'][self._name]['main_src_directory']
                for fpath in self._changed_files['src']:
                    short_path = fpath.replace('.java', '.class')
                    for src_dir in src_dirs:
                        if src_dir in short_path:
                            short_path = os.path.relpath(fpath, src_dir).replace('.java', '')
                            break

                    for clazz in classes:
                        if short_path + '.class' in clazz or short_path + '$' in clazz or 'R.class' in clazz \
                                or 'R$' in clazz or short_path + '_' in clazz:
                            include_file = os.path.join(target_dir, clazz)
                            if os.path.exists(include_file):
                                self.debug('incremental build lambda file: {}'.format(include_file))
                                include_files.append(include_file)

                include_files_param = os.pathsep.join(include_files)
                if len(include_files_param) > 3496:
                    include_files_path = os.path.join(self._cache_dir, self._name, 'retrolambda_inc.list')
                    self.__save_parms_to_file(include_files_path, include_files)
                    jar_args.append('-Dretrolambda.includedFile={}'.format(include_files_path))
                else:
                    jar_args.append('-Dretrolambda.includedFiles={}'.format(include_files_param))

            lambda_classpaths = [target_dir, lambda_config['rtJar']]
            lambda_classpaths.extend(self._classpaths)
            param = os.pathsep.join(lambda_classpaths)

            if lambda_config['supportIncludeFiles'] and len(param) > 3496:
                classpath_file = os.path.join(self._cache_dir, self._name, 'retrolambda_classpaths.path')
                self.__save_parms_to_file(classpath_file, lambda_classpaths)
                jar_args.append('-Dretrolambda.classpathFile={}'.format(classpath_file))
            else:
                jar_args.append('-Dretrolambda.classpath={}'.format(param))

            jar_args.append('-cp')
            jar_args.append(lambda_config['targetJar'])
            jar_args.append(lambda_config['mainClass'])

            self.debug('retrolambda exec: ' + ' '.join(jar_args))
            output, err, code = cexec(jar_args, callback=None)

            if code != 0:
                raise FreelineException('retrolambda compile failed.', '{}\n{}'.format(output, err))
开发者ID:BruceHurrican,项目名称:BruceDaily,代码行数:60,代码来源:gradle_inc_build.py


示例10: run_javac_task

    def run_javac_task(self):
        javacargs = [self._javac, '-encoding', 'UTF-8', '-g']
        if not self._is_retrolambda_enabled:
            javacargs.extend(['-target', '1.7', '-source', '1.7'])

        javacargs.append('-cp')
        javacargs.append(os.pathsep.join(self._classpaths))

        for fpath in self._changed_files['src']:
            javacargs.append(fpath)

        javacargs.extend(self._extra_javac_args)
        javacargs.append('-d')
        javacargs.append(self._finder.get_patch_classes_cache_dir())

        self.debug('javac exec: ' + ' '.join(javacargs))
        output, err, code = cexec(javacargs, callback=None)

        if code != 0:
            raise FreelineException('incremental javac compile failed.', '{}\n{}'.format(output, err))
        else:
            if self._is_r_file_changed:
                old_r_file = self._finder.get_dst_r_path(config=self._config)
                new_r_file = android_tools.DirectoryFinder.get_r_file_path(self._finder.get_backup_dir())
                shutil.copyfile(new_r_file, old_r_file)
                self.debug('copy {} to {}'.format(new_r_file, old_r_file))
开发者ID:BruceHurrican,项目名称:BruceDaily,代码行数:26,代码来源:gradle_inc_build.py


示例11: run_apt_only

    def run_apt_only(self):
        if self._is_databinding_enabled and self._should_run_databinding_apt():
            apt_args = self._generate_java_compile_args(extra_javac_args_enabled=True)
            self.debug('apt exec: ' + ' '.join(apt_args))
            output, err, code = cexec(apt_args, callback=None)

            if code != 0:
                raise FreelineException('apt compile failed.', '{}\n{}'.format(output, err))

            if self._apt_output_dir and os.path.exists(self._apt_output_dir):
                apt_cache_path = os.path.join(self._config['build_cache_dir'], 'apt_files_stat_cache.json')
                if os.path.exists(apt_cache_path):
                    apt_cache = load_json_cache(apt_cache_path)
                for dirpath, dirnames, files in os.walk(self._apt_output_dir):
                    for fn in files:
                        fpath = os.path.join(dirpath, fn)
                        if apt_cache and self._name in apt_cache:
                            if fpath in apt_cache[self._name]:
                                new_md5 = get_md5(fpath)
                                if new_md5 != apt_cache[self._name][fpath]['md5']:
                                    self.debug('detect new md5 value, add apt file to change list: {}'.format(fpath))
                                    self._changed_files['src'].append(fpath)
                            else:
                                self.debug('find new apt file, add to change list: {}'.format(fpath))
                                self._changed_files['src'].append(fpath)
                        else:
                            self.debug('apt cache not found, add to change list: {}'.format(fpath))
                            self._changed_files['src'].append(fpath)
开发者ID:fenglincanyi,项目名称:Study,代码行数:28,代码来源:gradle_inc_build.py


示例12: init

def init():
    project_dir = os.getcwd()
    symlink('freeline', project_dir, 'freeline.py')

    if is_windows:
        symlink('freeline', project_dir, 'freeline_core')

    from gradle_tools import get_all_modules
    modules = get_all_modules(project_dir)
    for m in modules:
        if is_main_project(m['path']):
            main_module = m
            break

    if not main_module:
        raise FreelineException('main module not found', 'set main module first')

    print('find main module: ' + main_module['name'])
    args = []
    if is_windows:
        args.append('gradlew.bat')
    else:
        args.append('./gradlew')
    args.append(':{}:checkBeforeCleanBuild'.format(main_module['name']))
    print('freeline is reading project info, please wait a moment...')
    output, err, code = cexec(args, cwd=project_dir)
    if code != 0:
        raise FreelineException('freeline failed when read project info with script: {}'.format(args),
                                '{}\n{}'.format(output, err))
    print('freeline init success')
开发者ID:568,项目名称:ThirdPlugin,代码行数:30,代码来源:init.py


示例13: check_installation

 def check_installation(self):
     commands = [self._adb, 'shell', 'pm', 'list', 'packages', self._config['debug_package']]
     self.debug(commands)
     output, err, code = cexec(commands, callback=None)
     result = re.findall(self._config['debug_package'].replace('.', '\.') + '\s', output)
     if len(result) == 1:
         return True
     return False
开发者ID:alibaba,项目名称:freeline,代码行数:8,代码来源:sync_client.py


示例14: check_installation

 def check_installation(self):
     commands = [self._adb, 'shell', 'pm', 'list', 'packages', self._config['package']]
     output, err, code = cexec(commands, callback=None)
     result = re.findall(self._config['package'].replace('.', '\.') + '\s+\Z', output)
     if len(result) != 1:
         self.debug('No package named {} been installed to your device'.format(self._config['package']))
         from exceptions import NoInstallationException
         raise NoInstallationException(
             'No package named {} been installed to your device'.format(self._config['package']),
             '\tUse `adb shell pm list packages {}` to check app installation.'.format(self._config['package']))
开发者ID:568,项目名称:ThirdPlugin,代码行数:10,代码来源:sync_client.py


示例15: execute

    def execute(self):
        command = './gradlew -q checkBeforeCleanBuild'
        if is_windows_system():
            command = 'gradlew.bat -q checkBeforeCleanBuild'

        output, err, code = cexec(command.split(' '), callback=None)
        if code != 0:
            from exceptions import FreelineException
            raise FreelineException('freeline failed when read project info with script: {}'.format(command),
                                    '{}\n{}'.format(output, err))
开发者ID:568,项目名称:ThirdPlugin,代码行数:10,代码来源:gradle_clean_build.py


示例16: get_device_sdk_version_by_adb

def get_device_sdk_version_by_adb(adb):
    dev_version = 0
    try:
        output = cexec([adb, 'shell', 'getprop ro.build.version.sdk'], callback=None)
        if output and len(output) > 0:
            if isinstance(output, str):
                dev_version = int(output.strip())
            elif isinstance(output, tuple):
                dev_version = int(output[0])
    except:
        pass
    return dev_version
开发者ID:Ryanst,项目名称:AndroidDemo,代码行数:12,代码来源:android_tools.py


示例17: _check_connection

 def _check_connection(self):
     self.debug('check device\' connection...')
     commands = [self._adb, 'devices']
     output, err, code = cexec(commands, callback=None)
     if code == 0:
         length = len(output.strip().split('\n'))
         from exceptions import UsbConnectionException
         if length < 2:
             raise UsbConnectionException('No device\'s connection found',
                                          '\tUse `adb devices` to check your device connection')
         if length > 2:
             raise UsbConnectionException('More than 1 device connect',
                                          '\tOnly 1 device allowed, '
                                          'use `adb devices` to check your devices\' connection')
开发者ID:Ryanst,项目名称:AndroidDemo,代码行数:14,代码来源:android_tools.py


示例18: scan_device_port

    def scan_device_port(self, sync_value, uuid):
        port = 0

        for i in range(0, 10):
            cexec([self._adb, 'forward', 'tcp:{}'.format(PORT_START + i), 'tcp:{}'.format(PORT_START + i)],
                  callback=None)
            url = 'http://127.0.0.1:{}/getSyncTicket'.format(PORT_START + i)
            self.debug('url===='+url)
            result, err, code = curl(url)
            if code == 0 and result is not None:
                try:
                    result = json.loads(result.replace("'", '"'))
                    self.debug(result)
                    if result["apkBuildFlag"] == uuid:
                        port = PORT_START + i
                        break
                    elif result["apkBuildFlag"] is not None:
                        self.debug('apkBuildFlag: {} does not match uuid: {}'.format(result["apkBuildFlag"], uuid))
                        port = -1
                        break
                        
                except Exception, e:
                    pass
开发者ID:alibaba,项目名称:freeline,代码行数:23,代码来源:sync_client.py


示例19: execute

 def execute(self):
     if is_src_changed(self._cache_dir):
         pending_merge_dexes = self._get_dexes()
         dex_path = get_incremental_dex_path(self._cache_dir)
         if len(pending_merge_dexes) == 1:
             self.debug('just 1 dex need to sync, copy {} to {}'.format(pending_merge_dexes[0], dex_path))
             shutil.copy(pending_merge_dexes[0], dex_path)
         elif len(pending_merge_dexes) > 1:
             dex_path = get_incremental_dex_path(self._cache_dir)
             dex_merge_args = ['java', '-jar', os.path.join('freeline', 'release-tools', 'DexMerge.jar'), dex_path]
             dex_merge_args.extend(pending_merge_dexes)
             self.debug('merge dex exec: ' + ' '.join(dex_merge_args))
             output, err, code = cexec(dex_merge_args, callback=None)
             if code != 0:
                 raise FreelineException('merge dex failed: {}'.format(' '.join(dex_merge_args)),
                                         output + '\n' + err)
开发者ID:Ryanst,项目名称:AndroidDemo,代码行数:16,代码来源:android_tools.py


示例20: execute

    def execute(self):
        # reload config
        from dispatcher import read_freeline_config
        self._config = read_freeline_config()

        cwd = self._config['build_script_work_directory'].strip()
        if not cwd or not os.path.isdir(cwd):
            cwd = None

        output, err, code = cexec(self._config['build_script'].split(' '), callback=None, cwd=cwd)
        self.debug(self._config['build_script'])
        self.debug("Gradle build task is running, please wait a minute...")
        if code != 0:
            from exceptions import FreelineException
            raise FreelineException('build failed with script: {}'.format(self._config['build_script']),
                                    '{}\n{}'.format(output, err))
开发者ID:ccyingzi2009,项目名称:Weather,代码行数:16,代码来源:gradle_clean_build.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.changeExt函数代码示例发布时间:2022-05-26
下一篇:
Python utils.cdf_to_pdf函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap