本文整理汇总了Python中sync.Sync类的典型用法代码示例。如果您正苦于以下问题:Python Sync类的具体用法?Python Sync怎么用?Python Sync使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sync类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
parser = argparse.ArgumentParser(description='Sync current folder to your flickr account.')
parser.add_argument('--monitor', action='store_true', help='starts a daemon after sync for monitoring')
parser.add_argument('--starts-with', type=str, help='only sync that path that starts with')
parser.add_argument('--download', type=str, help='download the photos from flickr specify a path or . for all')
parser.add_argument('--ignore-videos', action='store_true', help='ignore video files')
parser.add_argument('--ignore-images', action='store_true', help='ignore image files')
parser.add_argument('--version', action='store_true', help='output current version')
parser.add_argument('--sync-path', type=str, default=os.getcwd(),
help='specify the sync folder (default is current dir)')
parser.add_argument('--custom-set', type=str, help='customize your set name from path with regex')
parser.add_argument('--custom-set-builder', type=str, help='build your custom set title (default just merge groups)')
parser.add_argument('--update-custom-set', action='store_true', help='updates your set title from custom set')
parser.add_argument('--username', type=str, help='token username') #token username argument for api
parser.add_argument('--keyword', action='append', type=str, help='only upload files matching this keyword')
args = parser.parse_args()
if args.version:
# todo get from setup.cfg
logger.info('v0.1.17')
exit()
# validate args
args.is_windows = os.name == 'nt'
args.sync_path = args.sync_path.rstrip(os.sep) + os.sep
if not os.path.exists(args.sync_path):
logger.error('Sync path does not exists')
exit(0)
local = Local(args)
remote = Remote(args)
sync = Sync(args, local, remote)
sync.start_sync()
示例2: run
def run(self):
sync = Sync(show_progress=self._isManual, run_silent=self._runSilent, api=globals.traktapi)
sync.sync()
if utilities.getSettingAsBool('tagging_enable') and utilities.getSettingAsBool('tagging_tag_after_sync'):
q = queue.SqliteQueue()
q.append({'action': 'updateTags'})
示例3: sync
def sync(self, dst, event):
"""Sync pdb-rest.db to to local target"""
pdbsync = Sync(
self,
dst,
event)
pdbsync.run()
示例4: main
def main():
parser = argparse.ArgumentParser(description='Sync current folder to your flickr account.')
parser.add_argument('--monitor', action='store_true',
help='starts a daemon after sync for monitoring')
parser.add_argument('--dry-run', action='store_true',
help='do not perform any remote action')
parser.add_argument('--starts-with', type=str,
help='only sync that path starts with this text, e.g. "2015/06"')
parser.add_argument('--download', type=str,
help='download the photos from flickr, specify a path or . for all')
parser.add_argument('--ignore-videos', action='store_true',
help='ignore video files')
parser.add_argument('--ignore-images', action='store_true',
help='ignore image files')
parser.add_argument('--ignore-ext', type=str,
help='comma separated list of extensions to ignore, e.g. "jpg,png"')
parser.add_argument('--version', action='store_true',
help='output current version: ' + version)
parser.add_argument('--sync-path', type=str, default=os.getcwd(),
help='specify the sync folder (default is current dir)')
parser.add_argument('--sync-from', type=str,
help='Only supported value: "all". Uploads anything that isn\'t on flickr, and download anything that isn\'t on the local filesystem')
parser.add_argument('--custom-set', type=str,
help='customize your set name from path with regex, e.g. "(.*)/(.*)"')
parser.add_argument('--custom-set-builder', type=str,
help='build your custom set title, e.g. "{0} {1}" to join the first two groups (default merges groups with hyphen)')
parser.add_argument('--update-custom-set', action='store_true',
help='updates your set title from custom-set (and custom-set-builder, if given)')
parser.add_argument('--custom-set-debug', action='store_true',
help='for testing your custom sets, asks for confirmation when creating an album on flickr')
parser.add_argument('--username', type=str,
help='token username') # token username argument for api
parser.add_argument('--add-photo-prefix', type=str,
help='Add a specific prefix to the remote files whose local files have that prefix')
parser.add_argument('--iphoto', action='store_true',
help='Backup iPhoto Masters folder')
parser.add_argument('--keyword', action='append', type=str,
help='only upload files matching this keyword')
args = parser.parse_args()
if args.version:
logger.info(version)
exit()
# validate args
args.is_windows = os.name == 'nt'
args.sync_path = args.sync_path.rstrip(os.sep) + os.sep
if not os.path.exists(args.sync_path):
logger.error('Sync path does not exists')
exit(0)
local = Local(args)
remote = Remote(args)
sync = Sync(args, local, remote)
sync.start_sync()
示例5: main
def main():
parser = argparse.ArgumentParser(description="Sync current folder to your flickr account.")
parser.add_argument("--monitor", action="store_true", help="starts a daemon after sync for monitoring")
parser.add_argument("--starts-with", type=str, help='only sync that path starts with this text, e.g. "2015/06"')
parser.add_argument("--download", type=str, help="download the photos from flickr, specify a path or . for all")
parser.add_argument("--ignore-videos", action="store_true", help="ignore video files")
parser.add_argument("--ignore-images", action="store_true", help="ignore image files")
parser.add_argument("--ignore-ext", type=str, help='comma separated list of extensions to ignore, e.g. "jpg,png"')
parser.add_argument("--version", action="store_true", help="output current version: " + version)
parser.add_argument(
"--sync-path", type=str, default=os.getcwd(), help="specify the sync folder (default is current dir)"
)
parser.add_argument(
"--sync-from",
type=str,
help="Only supported value: \"all\". Uploads anything that isn't on flickr, and download anything that isn't on the local filesystem",
)
parser.add_argument("--custom-set", type=str, help='customize your set name from path with regex, e.g. "(.*)/(.*)"')
parser.add_argument(
"--custom-set-builder",
type=str,
help='build your custom set title, e.g. "{0} {1}" to join the first two groups (default merges groups with hyphen)',
)
parser.add_argument(
"--update-custom-set",
action="store_true",
help="updates your set title from custom-set (and custom-set-builder, if given)",
)
parser.add_argument(
"--custom-set-debug",
action="store_true",
help="for testing your custom sets, asks for confirmation when creating an album on flickr",
)
parser.add_argument("--username", type=str, help="token username") # token username argument for api
parser.add_argument("--keyword", action="append", type=str, help="only upload files matching this keyword")
args = parser.parse_args()
if args.version:
logger.info(version)
exit()
# validate args
args.is_windows = os.name == "nt"
args.sync_path = args.sync_path.rstrip(os.sep) + os.sep
if not os.path.exists(args.sync_path):
logger.error("Sync path does not exists")
exit(0)
local = Local(args)
remote = Remote(args)
sync = Sync(args, local, remote)
sync.start_sync()
示例6: run
def run(self):
"""
Thread: Run
"""
s = Sync(self.src, self.dst, **self.kwargs)
s.diff()
self.loadInitContents(s)
s.progressfnc = self.progress
while True:
s.diff()
s.difftrim(create=self.getInitContents())
s.run()
time.sleep(self.freq)
示例7: onLogin
def onLogin(self, host, username, passwd, ssl):
"""
Slot. Triggers a log in request to the server.
:param host: Indicates the hostname of the FTP server
:param username: Username to log in into the FTP server
:param passwd: Password to log in into the FTP server
:param ssl: Indicates whether the FTP needs SSL support
"""
self.sync = Sync(host, ssl)
self.syncStarted.connect(self.sync.initQueue)
self.sync.server.downloadProgress.connect(self.onDownloadProgress)
self.sync.server.uploadProgress.connect(self.onUploadProgress)
self.sync.server.fileEvent.connect(self.onFileEvent)
self.sync.server.badFilenameFound.connect(self.badNameWarning)
self.sync.server.loginCompleted.connect(self.onLoginCompleted)
self.sync.server.fileEventCompleted.connect(self.onFileEventCompleted)
self.sync.server.ioError.connect(self.onIOError)
# Added by Si
self.sync.server.textStatus.connect(self.setStatus)
self.sync.statusChanged.connect(self.setStatus)
self.loginRequested.connect(self.sync.server.onLogin)
self.syncThread = QThread()
self.sync.moveToThread(self.syncThread)
self.syncThread.start()
QApplication.instance().lastWindowClosed.connect(self.syncThread.quit)
self.loginRequested.emit(username, passwd)
示例8: setUp
def setUp(self, glancesync):
"""create constructor, mock with glancesync, Set a master region"""
self.regions = []
self.sync = Sync(self.regions)
self.glancesync = glancesync
config = {'return_value.master_region': 'MasterRegion'}
self.glancesync.configure_mock(**config)
示例9: onShow
def onShow(self):
print(self.controller.get_srvAddr())
self.sync = Sync(srvAddr=self.controller.get_srvAddr(),conn=self.conn,session=self.controller.get_session())
if self.sync is not None:
self.sync.dosync()
self.remotePgmTotal = self.sync.getRemoteProgramTotalCount()
self.remoteTrackTotal = self.sync.getRemoteTrackTotalCount()
banner = Frame(self)
banner.grid(row=0,column=0,sticky="WE")
self.label = Label(banner,image=self.logo)
self.label.image = self.logo
self.label.pack()
body = Frame(self)
body.grid(row=1,column=0,sticky="NSWE")
Label(body,text="歌曲同步中...",padding=(10, 5, 10, 5)).grid(row=1,column=0,sticky="WE")
self.pgb_media = Progressbar(body, orient="horizontal", length=200, mode="determinate")
self.pgb_media.grid(row=1,column=1,sticky="WE")
self.pgb_media["value"]=0
self.pgb_media["maximum"]=self.remoteTrackTotal
self.sync.start()
self.checkstatus()
示例10: run
def run(self, orig_args):
options,args = self.parser.parse_args(orig_args)
args = args[1:]
if len(args) <= 0:
self.print_usage()
return
project_dir = self.git.module_name(args[0])
if project_dir == None or len(project_dir) <= 0:
print("Unknow project name.Please use git clone, then use mgit sync in the project dir.")
return
cmd = ['git', 'clone'] + args
if options.branch != None:
cmd += ["-b", options.branch]
if 0 != os.system(" ".join(cmd)):
return
cwd = os.getcwd()
os.chdir("/".join([cwd, project_dir]))
sync = Sync()
sync.run(['sync'] + orig_args[1:])
os.chdir(cwd)
示例11: Execute
def Execute(self, opt, args):
if os.path.exists(os.path.join(self.repodir, "projects")):
print >>sys.stderr, "this working directory has already been cloned into. exiting."
sys.exit(1)
#run Sync to clone the repos into the tree the way Repo expects them
sync_cmd = Sync()
sync_cmd.NAME = 'sync'
sync_cmd.manifest = self.manifest
sync_cmd.repodir = self.repodir
argv = sys.argv
argv = argv[argv.index('--')+2:]
newopts, newargs = sync_cmd.OptionParser.parse_args(argv)
sync_cmd.Execute(newopts, newargs)
#checkout master everywhere
for project in self.GetProjects(''):
print >>sys.stdout, "%s:" % project.name
out = project.work_git.checkout("-t", "-b", "master", "remotes/origin/master")
print >>sys.stdout, out
print >>sys.stdout
示例12: op_sync
def op_sync (self):
conf = self.get_config()
pname = self._load_profile()
sync = Sync(conf, pname, self.get_db(), dr=self.is_dry_run())
if self.is_dry_run():
sync.prep_lists(self.get_sync_dir())
else:
try:
startt = conf.get_curr_time()
result = sync.sync(self.get_sync_dir())
if result:
conf.set_last_sync_start(pname, val=startt)
conf.set_last_sync_stop(pname)
logging.info('Updating item inventory...')
sync.save_item_lists()
logging.info('Updating item inventory...done')
else:
logging.info('timestamps not reset for profile %s due to '
'errors (previously identified).', pname)
except Exception, e:
logging.critical('Exception (%s) while syncing profile %s',
str(e), pname)
logging.critical(traceback.format_exc())
return False
示例13: TestSync
class TestSync(unittest.TestCase):
"""Class to test all methods but constructor and parallel sync"""
@patch('sync.GlanceSync', auto_spec=True)
def setUp(self, glancesync):
"""create constructor, mock with glancesync, Set a master region"""
self.regions = []
self.sync = Sync(self.regions)
self.glancesync = glancesync
config = {'return_value.master_region': 'MasterRegion'}
self.glancesync.configure_mock(**config)
def test_report_status(self):
"""check that calls to export_sync_region_status are done"""
self.sync.regions = ['region1', 'region2']
self.sync.report_status()
calls = [call('region1', ANY), call('region2', ANY)]
self.glancesync.return_value.export_sync_region_status.\
assert_has_calls(calls)
def test_sequential_sync(self):
"""check that calls to sync_region are done"""
self.sync.regions = ['region1', 'region2']
self.sync.sequential_sync(dry_run=True)
calls = [call('region1', dry_run=True), call('region2', dry_run=True)]
self.glancesync.return_value.sync_region.assert_has_calls(calls)
def test_show_regions(self):
"""check that calls to get_regions are done"""
targets = {'master': None, 'other_target': None}
config = {'return_value.targets': targets}
self.glancesync.configure_mock(**config)
self.sync.show_regions()
calls = [call(), call(target='other_target')]
self.glancesync.return_value.get_regions.assert_has_calls(calls)
@patch('sync.os')
@patch('sync.datetime')
def test_make_backup(self, datetime_mock, os_mock):
"""check make backup; calls are correct and mkdir is invoked with
right parameters"""
datetime_str = '2020-02-06T23:57:09.205378'
config = {'datetime.now.return_value.isoformat.return_value':
datetime_str}
datetime_mock.configure_mock(**config)
self.sync.make_backup()
dir_name = 'backup_glance_' + datetime_str
os_mock.mkdir.assert_called_with(dir_name)
self.glancesync.return_value.backup_glancemetadata_region.\
assert_called_with('MasterRegion', dir_name)
示例14: SyncFrame
class SyncFrame(Frame):
def __init__(self,master=None,controller=None,conn=None):
Frame.__init__(self,master)
self.controller = controller
self.conn = self.controller.get_conn()
self.logo = self.controller.get_logo()
self.remotePgmTotal = 0
self.remoteTrackTotal = 0
def onShow(self):
print(self.controller.get_srvAddr())
self.sync = Sync(srvAddr=self.controller.get_srvAddr(),conn=self.conn,session=self.controller.get_session())
if self.sync is not None:
self.sync.dosync()
self.remotePgmTotal = self.sync.getRemoteProgramTotalCount()
self.remoteTrackTotal = self.sync.getRemoteTrackTotalCount()
banner = Frame(self)
banner.grid(row=0,column=0,sticky="WE")
self.label = Label(banner,image=self.logo)
self.label.image = self.logo
self.label.pack()
body = Frame(self)
body.grid(row=1,column=0,sticky="NSWE")
Label(body,text="歌曲同步中...",padding=(10, 5, 10, 5)).grid(row=1,column=0,sticky="WE")
self.pgb_media = Progressbar(body, orient="horizontal", length=200, mode="determinate")
self.pgb_media.grid(row=1,column=1,sticky="WE")
self.pgb_media["value"]=0
self.pgb_media["maximum"]=self.remoteTrackTotal
self.sync.start()
self.checkstatus()
def checkstatus(self):
self.pgb_media["value"] = 0 if self.sync is None else self.sync.getTrackIdx()
if self.pgb_media["value"] >= self.remoteTrackTotal:
self.gotoMain()
else:
self.after(200,self.checkstatus)
def gotoMain(self):
print('going to main....')
self.controller.show_frame(EnvoMaster)
示例15: __init__
def __init__(self, port, virtual_world, camera_mgr, sync_session):
self.port = port
self.virtual_world = virtual_world
self.cam_mgr = camera_mgr
self.task_mgr = virtual_world.taskMgr
self.cManager = QueuedConnectionManager()
self.cListener = QueuedConnectionListener(self.cManager, 0)
self.cReader = QueuedConnectionReader(self.cManager, 0)
self.cReader.setRawMode(True)
self.cWriter = ConnectionWriter(self.cManager, 1)
self.cWriter.setRawMode(True)
self.tcpSocket = self.cManager.openTCPServerRendezvous(port, BACKLOG)
self.cListener.addConnection(self.tcpSocket)
self.activeSessions = {}
self.connection_map = {}
self.set_handlers()
hostname = socket.gethostname()
a, b, address_list = socket.gethostbyname_ex(hostname)
self.ip = address_list[0]
logging.info("Addresses %s" % address_list)
logging.info("Server is running on ip: %s, port: %s"
%(self.ip, self.port))
self.client_counter = 0
self.read_buffer = ''
self.read_state = 0
self.read_body_length = 0
self.packet = SocketPacket()
controller = virtual_world.getController()
self.sync = Sync(self.task_mgr, controller, camera_mgr, sync_session)
self.vv_id = None
if sync_session:
logging.info("Waiting for Sync Client!")
self.showing_info = False
virtual_world.accept("i", self.toggleInfo)
self.sync_session = sync_session
self.createInfoLabel()
atexit.register(self.exit)