def run_ocsync(local_folder, remote_folder="", n=None, user_num=None): """ Run the ocsync for local_folder against remote_folder (or the main folder on the owncloud account if remote_folder is None). Repeat the sync n times. If n given then n -> config.oc_sync_repeat (default 1). """ global ocsync_cnt from smashbox.utilities import reflection if n is None: n = config.oc_sync_repeat current_step = reflection.getCurrentStep() ocsync_cnt.setdefault(current_step, 0) local_folder += '/' # FIXME: HACK - is a trailing slash really needed by 1.6 owncloudcmd client? for i in range(n): t0 = datetime.datetime.now() cmd = config.oc_sync_cmd + ' ' + local_folder + ' ' + oc_webdav_url( 'owncloud', remote_folder, user_num ) + " >> " + config.rundir + "/%s-ocsync.step%02d.cnt%03d.log 2>&1" % ( reflection.getProcessName(), current_step, ocsync_cnt[current_step]) runcmd(cmd, ignore_exitcode=True) # exitcode of ocsync is not reliable logger.info('sync cmd is: %s', cmd) logger.info('sync finished: %s', datetime.datetime.now() - t0) ocsync_cnt[current_step] += 1
def run_ocsync(local_folder, remote_folder="", n=None, user_num=None): """ Run the ocsync for local_folder against remote_folder (or the main folder on the owncloud account if remote_folder is None). Repeat the sync n times. If n given then n -> config.oc_sync_repeat (default 1). """ global ocsync_cnt from smashbox.utilities import reflection if n is None: n = config.oc_sync_repeat current_step = reflection.getCurrentStep() ocsync_cnt.setdefault(current_step,0) if platform.system() != "Windows": local_folder += os.sep # FIXME: HACK - is a trailing slash really needed by 1.6 owncloudcmd client? for i in range(n): t0 = datetime.datetime.now() cmd = config.oc_sync_cmd+[local_folder,oc_webdav_url('owncloud',remote_folder,user_num)] logf = file(os.path.join(config.rundir,"%s-ocsync.step%02d.cnt%03d.log"%(reflection.getProcessName(),current_step,ocsync_cnt[current_step])),"wb") logger.info('sync cmd is: %s',repr(cmd)) process = subprocess.Popen(cmd, shell=False, stdout=logf, stderr=subprocess.STDOUT) process.communicate() if process.returncode != 0: msg = "Non-zero exit code %d from command %s" % (process.returncode, repr(cmd)) logger.warning(msg) logger.info('sync finished: %s',datetime.datetime.now()-t0) ocsync_cnt[current_step]+=1
def run_ocsync(local_folder, remote_folder="", n=None, user_num=None): """ Run the ocsync for local_folder against remote_folder (or the main folder on the owncloud account if remote_folder is None). Repeat the sync n times. If n given then n -> config.oc_sync_repeat (default 1). """ global ocsync_cnt from smashbox.utilities import reflection if n is None: n = config.oc_sync_repeat current_step = reflection.getCurrentStep() ocsync_cnt.setdefault(current_step,0) local_folder += '/' # FIXME: HACK - is a trailing slash really needed by 1.6 owncloudcmd client? for i in range(n): t0 = datetime.datetime.now() cmd = config.oc_sync_cmd+' '+local_folder+' '+oc_webdav_url('owncloud',remote_folder,user_num) + " >> "+config.rundir+"/%s-ocsync.step%02d.cnt%03d.log 2>&1"%(reflection.getProcessName(),current_step,ocsync_cnt[current_step]) runcmd(cmd, ignore_exitcode=True) # exitcode of ocsync is not reliable logger.info('sync cmd is: %s',cmd) logger.info('sync finished: %s',datetime.datetime.now()-t0) ocsync_cnt[current_step]+=1
def run_ocsync(local_folder, remote_folder="", n=None, user_num=None, option = None): """ Run the ocsync for local_folder against remote_folder (or the main folder on the owncloud account if remote_folder is None). Repeat the sync n times. If n given then n -> config.oc_sync_repeat (default 1). Option parameters is used in case of non-native engine and could specify specific behaviour of sync in the specific step. """ global ocsync_cnt,sync_exec_time_array from smashbox.utilities import reflection if n is None: n = config.oc_sync_repeat current_step = reflection.getCurrentStep() ocsync_cnt.setdefault(current_step,0) local_folder += '/' # FIXME: HACK - is a trailing slash really needed by 1.6 owncloudcmd client? for i in range(n): cmd = config.oc_sync_cmd+' '+local_folder+' '+oc_webdav_url('owncloud',remote_folder,user_num) + " >> "+config.rundir+"/%s-ocsync.step%02d.cnt%03d.log 2>&1"%(reflection.getProcessName(),current_step,ocsync_cnt[current_step]) sync_exec_time = sync_engine(cmd,option) sync_exec_time_array.append(sync_exec_time) logger.info('sync finished: %s s'%sync_exec_time) ocsync_cnt[current_step]+=1
def run_ocsync(local_folder,remote_folder="",N=None): """ Run the ocsync for local_folder against remote_folder (or the main folder on the owncloud account if remote_folder is None). Repeat the sync N times. If N not given then N -> config.oc_sync_repeat (default 1). """ global ocsync_cnt from smashbox.utilities import reflection if N is None: N = config.oc_sync_repeat for i in range(N): t0 = datetime.datetime.now() cmd = config.oc_sync_cmd+' '+local_folder+' '+oc_webdav_url('owncloud',remote_folder)+" >> "+ config.rundir+"/%s-ocsync.step%02d.cnt%03d.log 2>&1"%(reflection.getProcessName(),reflection.getCurrentStep(),ocsync_cnt) runcmd(cmd,ignore_exitcode=True) # exitcode of ocsync is not reliable logger.info('sync finished: %s',datetime.datetime.now()-t0) ocsync_cnt+=1