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


Python mozfile.remove函数代码示例

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


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

示例1: check_for_crashes

 def check_for_crashes(self, test_name=None):
     test_name = test_name or self.last_test
     dump_dir = self.device.pull_minidumps()
     crashed = BaseRunner.check_for_crashes(
         self, dump_directory=dump_dir, test_name=test_name)
     mozfile.remove(dump_dir)
     return crashed
开发者ID:qiuyang001,项目名称:Spidermonkey,代码行数:7,代码来源:device.py

示例2: process_test_job

def process_test_job(data):
    global logger
    logger = logger or structuredlog.get_default_logger()

    build_name = "{}-{} {}".format(data['platform'], data['buildtype'], data['test'])
    logger.debug("now processing a '{}' job".format(build_name))

    log_url = None
    for name, url in data['blobber_files'].iteritems():
        if name in settings['structured_log_names']:
            log_url = url
            break
    log_path = _download_log(log_url)

    try:
        backend = settings['datastore']
        db_args = config.database
        store = get_storage_backend(backend, **db_args)

        # TODO commit metadata about the test run

        handler = StoreResultsHandler(store)
        with open(log_path, 'r') as log:
            iterator = reader.read(log)
            reader.handle_log(iterator, handler)
    finally:
        mozfile.remove(log_path)
开发者ID:ahal,项目名称:structured-catalog,代码行数:27,代码来源:worker.py

示例3: vendor

 def vendor(self, ignore_modified=False):
     self.populate_logger()
     self.log_manager.enable_unstructured()
     if not ignore_modified:
         self.check_modified_files()
     cargo = self.get_cargo_path()
     if not self.check_cargo_version(cargo):
         self.log(logging.ERROR, 'cargo_version', {}, 'Cargo >= 0.13 required (install Rust 1.12 or newer)')
         return
     else:
         self.log(logging.DEBUG, 'cargo_version', {}, 'cargo is new enough')
     have_vendor = any(l.strip() == 'vendor' for l in subprocess.check_output([cargo, '--list']).splitlines())
     if not have_vendor:
         self.log(logging.INFO, 'installing', {}, 'Installing cargo-vendor')
         self.run_process(args=[cargo, 'install', 'cargo-vendor'])
     else:
         self.log(logging.DEBUG, 'cargo_vendor', {}, 'cargo-vendor already intalled')
     vendor_dir = mozpath.join(self.topsrcdir, 'third_party/rust')
     self.log(logging.INFO, 'rm_vendor_dir', {}, 'rm -rf %s' % vendor_dir)
     mozfile.remove(vendor_dir)
     # Once we require a new enough cargo to switch to workspaces, we can
     # just do this once on the workspace root crate.
     for crate_root in ('toolkit/library/rust/',
                        'toolkit/library/gtest/rust'):
         path = mozpath.join(self.topsrcdir, crate_root)
         self._run_command_in_srcdir(args=[cargo, 'generate-lockfile', '--manifest-path', mozpath.join(path, 'Cargo.toml')])
         self._run_command_in_srcdir(args=[cargo, 'vendor', '--sync', mozpath.join(path, 'Cargo.lock'), vendor_dir])
     #TODO: print stats on size of files added/removed, warn or error
     # when adding very large files (bug 1306078)
     self.repository.add_remove_files(vendor_dir)
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:30,代码来源:vendor_rust.py

示例4: python_test

 def python_test(self, *args, **kwargs):
     try:
         tempdir = os.environ[b'PYTHON_TEST_TMP'] = str(tempfile.mkdtemp(suffix='-python-test'))
         return self.run_python_tests(*args, **kwargs)
     finally:
         import mozfile
         mozfile.remove(tempdir)
开发者ID:mykmelez,项目名称:spidernode,代码行数:7,代码来源:mach_commands.py

示例5: computeSNRAndDelay

    def computeSNRAndDelay(self):
        snr_delay = "-1.000,-1"

        if not os.path.exists(_MEDIA_TOOLS_):
            return False, "SNR Tool not found"

        cmd = [_MEDIA_TOOLS_, '-c', 'snr', '-r', _INPUT_FILE_, '-t',
               _RECORDED_NO_SILENCE_]
        cmd = [str(s) for s in cmd]

        output = subprocess.check_output(cmd)
        # SNR_Delay=1.063,5
        result = re.search('SNR_DELAY=(\d+\.\d+),(\d+)', output)

        # delete the recorded file with no silence
        mozfile.remove(_RECORDED_NO_SILENCE_)

        if result:
            snr_delay = str(result.group(1)) + ',' + str(result.group(2))
            return True, snr_delay
        else:
            """
            We return status as True since SNR computation went through
            successfully but scores computation failed due to severly
            degraded audio quality.
            """
            return True, snr_delay
开发者ID:kleopatra999,项目名称:system-addons,代码行数:27,代码来源:media_utils.py

示例6: setupProfile

    def setupProfile(self, prefs=None):
        """Sets up the user profile on the device.

        :param prefs: String of user_prefs to add to the profile. Defaults to a standard b2g testing profile.
        """
        # currently we have no custom prefs to set (when bug 800138 is fixed,
        # we will probably want to enable marionette on an external ip by
        # default)
        if not prefs:
            prefs = ""

        #remove previous user.js if there is one
        if not self.profileDir:
            self.profileDir = tempfile.mkdtemp()
        our_userJS = os.path.join(self.profileDir, "user.js")
        mozfile.remove(our_userJS)
        #copy profile
        try:
            self.getFile(self.userJS, our_userJS)
        except subprocess.CalledProcessError:
            pass
        #if we successfully copied the profile, make a backup of the file
        if os.path.exists(our_userJS):
            self.shellCheckOutput(['dd', 'if=%s' % self.userJS, 'of=%s.orig' % self.userJS])
        with open(our_userJS, 'a') as user_file:
            user_file.write("%s" % prefs)

        self.pushFile(our_userJS, self.userJS)
        self.restartB2G()
        self.setupMarionette()
开发者ID:Nicksol,项目名称:mozbase,代码行数:30,代码来源:b2gmixin.py

示例7: get_gaia_info

    def get_gaia_info(self, app_zip):
        tempdir = tempfile.mkdtemp()
        try:
            gaia_commit = os.path.join(tempdir, 'gaia_commit.txt')
            try:
                zip_file = zipfile.ZipFile(app_zip.name)
                with open(gaia_commit, 'w') as f:
                    f.write(zip_file.read('resources/gaia_commit.txt'))
            except zipfile.BadZipfile:
                self._logger.info('Unable to unzip application.zip, falling '
                                  'back to system unzip')
                from subprocess import call
                call(['unzip', '-j', app_zip.name, 'resources/gaia_commit.txt',
                      '-d', tempdir])

            with open(gaia_commit) as f:
                changeset, date = f.read().splitlines()
                self._info['gaia_changeset'] = re.match(
                    '^\w{40}$', changeset) and changeset or None
                self._info['gaia_date'] = date
        except KeyError:
                self._logger.warning(
                    'Unable to find resources/gaia_commit.txt in '
                    'application.zip')
        finally:
            mozfile.remove(tempdir)
开发者ID:DINKIN,项目名称:Waterfox,代码行数:26,代码来源:mozversion.py

示例8: pushDir

 def pushDir(self, localDir, remoteDir, retryLimit=None):
     # adb "push" accepts a directory as an argument, but if the directory
     # contains symbolic links, the links are pushed, rather than the linked
     # files; we either zip/unzip or re-copy the directory into a temporary
     # one to get around this limitation
     retryLimit = retryLimit or self.retryLimit
     if not self.dirExists(remoteDir):
         self.mkDirs(remoteDir+"/x")
     if self._useZip:
         try:
             localZip = tempfile.mktemp() + ".zip"
             remoteZip = remoteDir + "/adbdmtmp.zip"
             subprocess.Popen(["zip", "-r", localZip, '.'], cwd=localDir,
                              stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
             self.pushFile(localZip, remoteZip, retryLimit=retryLimit, createDir=False)
             mozfile.remove(localZip)
             data = self._runCmd(["shell", "unzip", "-o", remoteZip,
                                  "-d", remoteDir]).stdout.read()
             self._checkCmd(["shell", "rm", remoteZip],
                            retryLimit=retryLimit)
             if re.search("unzip: exiting", data) or re.search("Operation not permitted", data):
                 raise Exception("unzip failed, or permissions error")
         except:
             self._logger.info("zip/unzip failure: falling back to normal push")
             self._useZip = False
             self.pushDir(localDir, remoteDir, retryLimit=retryLimit)
     else:
         tmpDir = tempfile.mkdtemp()
         # copytree's target dir must not already exist, so create a subdir
         tmpDirTarget = os.path.join(tmpDir, "tmp")
         shutil.copytree(localDir, tmpDirTarget)
         self._checkCmd(["push", tmpDirTarget, remoteDir], retryLimit=retryLimit)
         mozfile.remove(tmpDir)
开发者ID:Nicksol,项目名称:mozbase,代码行数:33,代码来源:devicemanagerADB.py

示例9: remove_addon

    def remove_addon(self, addon_id):
        """Remove the add-on as specified by the id

        :param addon_id: id of the add-on to be removed
        """
        path = self.get_addon_path(addon_id)
        mozfile.remove(path)
开发者ID:JasonGross,项目名称:mozjs,代码行数:7,代码来源:addons.py

示例10: getDirectory

 def getDirectory(self, remoteDir, localDir, checkDir=True):
     localDir = os.path.normpath(localDir)
     remoteDir = os.path.normpath(remoteDir)
     copyRequired = False
     originalLocal = localDir
     if self._adb_version >= '1.0.36' and \
        os.path.isdir(localDir) and self.dirExists(remoteDir):
         # See do_sync_pull in
         # https://android.googlesource.com/platform/system/core/+/master/adb/file_sync_client.cpp
         # Work around change in behavior in adb 1.0.36 where if
         # the local destination directory exists, adb pull will
         # copy the source directory *into* the destination
         # directory otherwise it will copy the source directory
         # *onto* the destination directory.
         #
         # If the destination directory does exist, pull to its
         # parent directory. If the source and destination leaf
         # directory names are different, pull the source directory
         # into a temporary directory and then copy the temporary
         # directory onto the destination.
         localName = os.path.basename(localDir)
         remoteName = os.path.basename(remoteDir)
         if localName != remoteName:
             copyRequired = True
             tempParent = tempfile.mkdtemp()
             localDir = os.path.join(tempParent, remoteName)
         else:
             localDir = '/'.join(localDir.rstrip('/').split('/')[:-1])
     self._runCmd(["pull", remoteDir, localDir]).wait()
     if copyRequired:
         dir_util.copy_tree(localDir, originalLocal)
         mozfile.remove(tempParent)
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:32,代码来源:devicemanagerADB.py

示例11: clean

    def clean(self):
        """Clean up addons in the profile."""

        # Remove all add-ons installed
        for addon in self._addons:
            # TODO (bug 934642)
            # Once we have a proper handling of add-ons we should kill the id
            # from self._addons once the add-on is removed. For now lets forget
            # about the exception
            try:
                self.remove_addon(addon)
            except IOError:
                pass

        # Remove all downloaded add-ons
        for addon in self.downloaded_addons:
            mozfile.remove(addon)

        # restore backups
        if self.backup_dir and os.path.isdir(self.backup_dir):
            extensions_path = os.path.join(self.profile, 'extensions', 'staged')

            for backup in os.listdir(self.backup_dir):
                backup_path = os.path.join(self.backup_dir, backup)
                shutil.move(backup_path, extensions_path)

            if not os.listdir(self.backup_dir):
                mozfile.remove(self.backup_dir)

        # reset instance variables to defaults
        self._internal_init()
开发者ID:MichaelKohler,项目名称:gecko-dev,代码行数:31,代码来源:addons.py

示例12: __iter__

    def __iter__(self):
        for path, extra in self.dump_files:
            rv = self._process_dump_file(path, extra)
            yield rv

        if self.remove_symbols:
            mozfile.remove(self.symbols_path)
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:7,代码来源:mozcrash.py

示例13: cleanup_pending_crash_reports

def cleanup_pending_crash_reports():
    """
    Delete any pending crash reports.

    The presence of pending crash reports may be reported by the browser,
    affecting test results; it is best to ensure that these are removed
    before starting any browser tests.

    Firefox stores pending crash reports in "<UAppData>/Crash Reports".
    If the browser is not running, it cannot provide <UAppData>, so this
    code tries to anticipate its value.

    See dom/system/OSFileConstants.cpp for platform variations of <UAppData>.
    """
    if mozinfo.isWin:
        location = os.path.expanduser("~\\AppData\\Roaming\\Mozilla\\Firefox\\Crash Reports")
    elif mozinfo.isMac:
        location = os.path.expanduser("~/Library/Application Support/firefox/Crash Reports")
    else:
        location = os.path.expanduser("~/.mozilla/firefox/Crash Reports")
    logger = get_logger()
    if os.path.exists(location):
        try:
            mozfile.remove(location)
            logger.info("Removed pending crash reports at '%s'" % location)
        except:
            pass
开发者ID:subsevenx2001,项目名称:gecko-dev,代码行数:27,代码来源:mozcrash.py

示例14: fetch_and_unpack

 def fetch_and_unpack(self, revision, target):
     '''Fetch and unpack upstream source'''
     url = self.upstream_snapshot(revision)
     self.log(logging.INFO, 'fetch', {'url': url}, 'Fetching {url}')
     prefix = 'aom-' + revision
     filename = prefix + '.tar.gz'
     with open(filename, 'wb') as f:
         req = requests.get(url, stream=True)
         for data in req.iter_content(4096):
             f.write(data)
     tar = tarfile.open(filename)
     bad_paths = filter(lambda name: name.startswith('/') or '..' in name,
                        tar.getnames())
     if any(bad_paths):
         raise Exception("Tar archive contains non-local paths,"
                         "e.g. '%s'" % bad_paths[0])
     self.log(logging.INFO, 'rm_vendor_dir', {}, 'rm -rf %s' % target)
     mozfile.remove(target)
     self.log(logging.INFO, 'unpack', {}, 'Unpacking upstream files.')
     tar.extractall(target)
     # Github puts everything properly down a directory; move it up.
     if all(map(lambda name: name.startswith(prefix), tar.getnames())):
         tardir = mozpath.join(target, prefix)
         os.system('mv %s/* %s/.* %s' % (tardir, tardir, target))
         os.rmdir(tardir)
     # Remove the tarball.
     mozfile.remove(filename)
开发者ID:luke-chang,项目名称:gecko-1,代码行数:27,代码来源:vendor_aom.py

示例15: _run_tests

        def _run_tests(tags):
            application_folder = None

            try:
                # Backup current tags
                test_tags = self.test_tags

                application_folder = self.duplicate_application(source_folder)
                self.bin = mozinstall.get_binary(application_folder, 'Firefox')

                self.test_tags = tags
                super(UpdateTestRunner, self).run_tests(tests)

            except Exception:
                self.exc_info = sys.exc_info()
                self.logger.error('Failure during execution of the update test.',
                                  exc_info=self.exc_info)

            finally:
                self.test_tags = test_tags

                self.logger.info('Removing copy of the application at "%s"' % application_folder)
                try:
                    mozfile.remove(application_folder)
                except IOError as e:
                    self.logger.error('Cannot remove copy of application: "%s"' % str(e))
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:26,代码来源:update.py


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