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


Python os.sync方法代码示例

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


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

示例1: disrupt

# 需要导入模块: import os [as 别名]
# 或者: from os import sync [as 别名]
def disrupt(self):
        L.describe('Set the DNS servers in resolv.conf to public DNS servers')

        temp_resolv_conf = open(self._temp_resolv_conf_path, "w")
        # TODO: make configurable?
        dns_servers = ['37.235.1.174', '37.235.1.177']
        for nameserver in dns_servers:
            temp_resolv_conf.write("nameserver {}\n".format(nameserver))
        temp_resolv_conf.close()

        if os.path.islink(self._resolv_conf_path) and os.path.exists(self._resolv_conf_path):
            self._resolv_conf_target_path = os.readlink(self._resolv_conf_path)
            os.remove(self._resolv_conf_path)
            os.symlink(self._temp_resolv_conf_path, self._resolv_conf_path)
            os.sync()
        else:
            raise XVEx("Can't replace resolv.conf; not a symlink") 
开发者ID:expressvpn,项目名称:expressvpn_leak_testing,代码行数:19,代码来源:linux_dns_force_public_resolv_conf.py

示例2: download

# 需要导入模块: import os [as 别名]
# 或者: from os import sync [as 别名]
def download(self, make_dest_dir=True):
        with self.ftpc() as ftpc:
            if self.exists():
                # if the dest path does not exist
                if make_dest_dirs:
                    os.makedirs(os.path.dirname(
                        self.local_path, exists_ok=True))
                try:
                    ftpc.syncronize_times()
                except:
                    pass

                ftpc.download(source=self.remote_path, target=self.local_path)
                os.sync()
            else:
                raise FTPFileException(
                    "The file does not exist remotely: %s" % self.local_file()) 
开发者ID:cgat-developers,项目名称:cgat-core,代码行数:19,代码来源:ftp.py

示例3: delete_item

# 需要导入模块: import os [as 别名]
# 或者: from os import sync [as 别名]
def delete_item(item_path):
	failed = 0
	while os.path.exists(item_path):
		try:
			shutil.rmtree(item_path)
		except Exception as e:
			print("TryDelete failed!")
			print("Item: ", item_path)
			print("Stat: ", os.stat(item_path))
			failed += 1
			if failed > 20:
				print("Deletion failed!")
				return

			# You need an explicit sync call or the load_zips call can sometimes miss the new files.
			# Yes, this was actually an issue.
			os.sync()
			time.sleep(0.1 * failed)

			# Force the destructors to run in case we have the handle open still, somehow.
			gc.collect()

			os.stat(item_path)
			if not os.path.exists(item_path):
				return 
开发者ID:fake-name,项目名称:IntraArchiveDeduplicator,代码行数:27,代码来源:basePhashTestSetup.py

示例4: __init__

# 需要导入模块: import os [as 别名]
# 或者: from os import sync [as 别名]
def __init__(self, tableName = None, load_database = True, *args, **kwargs):

		if tableName:
			self.tableName = self.tableName+"_"+tableName
		super().__init__(*args, **kwargs)

		self.hasher = TestHasher()

		if load_database:
			self.copy_zips()


			self.log.info("sync()ing")
			# You need an explicit sync call or the load_zips call can sometimes miss the new files.
			# Yes, this was actually an issue.
			os.sync()

			self.load_zips(TEST_ZIP_PATH)

			# Since the tree deliberately persists (it's a singleton), we have to /explicitly/ clobber it.
			self.unlocked_doLoad() 
开发者ID:fake-name,项目名称:IntraArchiveDeduplicator,代码行数:23,代码来源:basePhashTestSetup.py

示例5: __enter__

# 需要导入模块: import os [as 别名]
# 或者: from os import sync [as 别名]
def __enter__(self):
        if not self.is_relevant:
            return
        self.assert_no_access()
        try:
            gen.log("Unmounting %s" % self.usb_disk)
            os.sync() # This is needed because UDISK.unmount() can timeout.
            UDISKS.unmount(self.usb_disk)
        except dbus.exceptions.DBusException as e:
            gen.log("Unmount of %s has failed." % self.usb_disk)
            # This may get the partition mounted. Don't call!
            # self.exit_callback(details(self.usb_disk))
            raise UnmountError(e)
        gen.log("Unmounted %s" % self.usb_disk)
        return self 
开发者ID:mbusb,项目名称:multibootusb,代码行数:17,代码来源:usb.py

示例6: __exit__

# 需要导入模块: import os [as 别名]
# 或者: from os import sync [as 别名]
def __exit__(self, type_, value, traceback_):
        if not self.is_relevant:
            return
        os.sync()     # This should not be strictly necessary
        time.sleep(1)  # Yikes, mount always fails without this sleep().
        try:
            mount_point = UDISKS.mount(self.usb_disk)
            config.add_remounted(self.usb_disk)
            self.exit_callback(details(self.usb_disk))
        except dbus.exceptions.DBusException as e:
            raise MountError(e)
        gen.log("Mounted %s" % (self.usb_disk)) 
开发者ID:mbusb,项目名称:multibootusb,代码行数:14,代码来源:usb.py

示例7: maybe_mkdir

# 需要导入模块: import os [as 别名]
# 或者: from os import sync [as 别名]
def maybe_mkdir(path):
    try:
        os.mkdir(path)
    except:
        pass
    if not simulator:
        os.sync()

# path to store #reckless entropy 
开发者ID:cryptoadvance,项目名称:specter-diy,代码行数:11,代码来源:platform.py

示例8: sync

# 需要导入模块: import os [as 别名]
# 或者: from os import sync [as 别名]
def sync():
    try:
        os.sync()
    except:
        pass 
开发者ID:cryptoadvance,项目名称:specter-diy,代码行数:7,代码来源:platform.py

示例9: _restore_dns_servers

# 需要导入模块: import os [as 别名]
# 或者: from os import sync [as 别名]
def _restore_dns_servers(self):
        os.remove(self._resolv_conf_path)
        os.symlink(self._resolv_conf_target_path, self._resolv_conf_path)
        os.sync() 
开发者ID:expressvpn,项目名称:expressvpn_leak_testing,代码行数:6,代码来源:linux_dns_force_public_resolv_conf.py

示例10: download

# 需要导入模块: import os [as 别名]
# 或者: from os import sync [as 别名]
def download(self, bucket_name, key, file_dir):
        self._S3object.remote_download(bucket_name, key, file_dir)
        os.sync()  # ensure flush to disk
        return file_dir 
开发者ID:cgat-developers,项目名称:cgat-core,代码行数:6,代码来源:aws.py

示例11: download

# 需要导入模块: import os [as 别名]
# 或者: from os import sync [as 别名]
def download(self, make_dest_dir=True):
        with self.sftpc() as sftpc:
            if self.exists():
                # if the dest path does not exist
                if make_dest_dirs:
                    os.makedirs(os.path.dirname(
                        self.local_path, exists_ok=True))

                sftpc.get(remotepath=self.remote_path,
                          localpath=self.local_path, preserve_mtime=True)
                os.sync()
            else:
                raise SFTPFileException(
                    "The file cannot be parsed as an STFP path in "
                    "form 'host:port/path/to/file': %s" % self.local_file()) 
开发者ID:cgat-developers,项目名称:cgat-core,代码行数:17,代码来源:sftp.py

示例12: download

# 需要导入模块: import os [as 别名]
# 或者: from os import sync [as 别名]
def download(self, container_name, blob_name, file_dir):
        self._Azureobject.remote_download(container_name, blob_name, file_dir)
        os.sync()  # ensure flush to disk
        return file_dir 
开发者ID:cgat-developers,项目名称:cgat-core,代码行数:6,代码来源:azure.py

示例13: download

# 需要导入模块: import os [as 别名]
# 或者: from os import sync [as 别名]
def download(self, bucket_name, key, file_dir):
        self._GCobject.remote_download(bucket_name, key, file_dir)
        os.sync()
        return file_dir 
开发者ID:cgat-developers,项目名称:cgat-core,代码行数:6,代码来源:google_cloud.py

示例14: shutdown

# 需要导入模块: import os [as 别名]
# 或者: from os import sync [as 别名]
def shutdown(self):
        '''Call the dbus proxy to start the shutdown.'''
        if self._proxy:
            os.sync()
            self._proxy(*self._args) 
开发者ID:XuShaohua,项目名称:bcloud,代码行数:7,代码来源:Shutdown.py

示例15: save_obj

# 需要导入模块: import os [as 别名]
# 或者: from os import sync [as 别名]
def save_obj(obj, name):
    # print("Saving %s" % name)
    with open(name, 'wb') as f:
        pickle.dump(obj=obj, file=f)
        # os.sync() 
开发者ID:h2oai,项目名称:h2o4gpu,代码行数:7,代码来源:test_gpu_prediction_pickledmodel.py


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