need. sleep.
This commit is contained in:
parent
31ecf0b262
commit
e0a625853d
@ -44,25 +44,25 @@ def sync(args):
|
|||||||
cmd = [rsync] # the path to the binary
|
cmd = [rsync] # the path to the binary
|
||||||
cmd.extend(opts) # the arguments
|
cmd.extend(opts) # the arguments
|
||||||
# TODO: implement repos here?
|
# TODO: implement repos here?
|
||||||
cmd.append(os.path.join(mirror, '.')) # the path on the remote mirror
|
cmd.append(os.path.join(args['mirror'], '.')) # the path on the remote mirror
|
||||||
cmd.append(os.path.join(dest['path'], '.')) # the local destination
|
cmd.append(os.path.join(args['destination'], '.')) # the local destination
|
||||||
if os.path.isfile(lockfile):
|
if os.path.isfile(args['lockfile']):
|
||||||
with open(lockfile, 'r') as f:
|
with open(args['lockfile'], 'r') as f:
|
||||||
existingpid = f.read().strip()
|
existingpid = f.read().strip()
|
||||||
exit('!! A repo synchronization seems to already be running (PID: {0}). Quitting. !!'.format(existingpid))
|
exit('!! A repo synchronization seems to already be running (PID: {0}). Quitting. !!'.format(existingpid))
|
||||||
else:
|
else:
|
||||||
with open(lockfile, 'w') as f:
|
with open(args['lockfile'], 'w') as f:
|
||||||
f.write(str(os.getpid()))
|
f.write(str(os.getpid()))
|
||||||
with open(logfile, 'a') as log:
|
with open(args['logfile'], 'a') as log:
|
||||||
try:
|
try:
|
||||||
subprocess.call(cmd, stdout = log, stderr = subprocess.STDOUT)
|
subprocess.call(cmd, stdout = log, stderr = subprocess.STDOUT)
|
||||||
now = int(datetime.datetime.timestamp(datetime.datetime.utcnow()))
|
now = int(datetime.datetime.timestamp(datetime.datetime.utcnow()))
|
||||||
with open(os.path.join(dest['path'], 'lastsync'), 'w') as f:
|
with open(os.path.join(dest['path'], 'lastsync'), 'w') as f:
|
||||||
f.write(str(now) + '\n')
|
f.write(str(now) + '\n')
|
||||||
os.remove(lockfile)
|
os.remove(args['lockfile'])
|
||||||
except:
|
except:
|
||||||
os.remove(lockfile)
|
os.remove(args['lockfile'])
|
||||||
exit('!! The rsync has failed. See {0} for more details. !!'.format(logfile))
|
exit('!! The rsync has failed. See {0} for more details. !!'.format(args['logfile']))
|
||||||
return()
|
return()
|
||||||
|
|
||||||
def getDefaults():
|
def getDefaults():
|
||||||
|
Loading…
Reference in New Issue
Block a user