Commit 25d50bb5 authored by Łukasz Nowak's avatar Łukasz Nowak

- method name corresponds its functionality

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@25801 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 49858230
...@@ -493,7 +493,7 @@ class PoliteThreadingTCPServer(SocketServer.ThreadingTCPServer): ...@@ -493,7 +493,7 @@ class PoliteThreadingTCPServer(SocketServer.ThreadingTCPServer):
daemon_threads = True daemon_threads = True
allow_reuse_address = True allow_reuse_address = True
def main(address, port): def server(address, port):
server = PoliteThreadingTCPServer((address, port), TIDServer) server = PoliteThreadingTCPServer((address, port), TIDServer)
try: try:
try: try:
...@@ -703,7 +703,7 @@ if options.fork: ...@@ -703,7 +703,7 @@ if options.fork:
os.close(1) os.close(1)
os.close(2) os.close(2)
sys.stdout = sys.stderr = logfile sys.stdout = sys.stderr = logfile
main(options.address, options.port) server(options.address, options.port)
log('Exiting.') log('Exiting.')
else: else:
pidfile.write(str(pid)) pidfile.write(str(pid))
...@@ -712,5 +712,5 @@ if options.fork: ...@@ -712,5 +712,5 @@ if options.fork:
else: else:
os._exit(0) os._exit(0)
else: else:
main(options.address, options.port) server(options.address, options.port)
...@@ -298,43 +298,46 @@ def parseargs(): ...@@ -298,43 +298,46 @@ def parseargs():
return options return options
options = parseargs() def main():
address = (options.host, options.port) options = parseargs()
zope_formated_url = options.base_url address = (options.host, options.port)
if options.base_url is not None and '%s' not in zope_formated_url: zope_formated_url = options.base_url
raise ValueError, 'Given base url (%r) is not properly formated, it must contain one \'%%s\'.' % (zope_formated_url, ) if options.base_url is not None and '%s' not in zope_formated_url:
repozo_formated_command = '%s %s -r "%%s"' % (options.repozo_file_name, ' '.join(options.repozo_opts)) raise ValueError, 'Given base url (%r) is not properly formated, it must contain one \'%%s\'.' % (zope_formated_url, )
if options.recover: repozo_formated_command = '%s %s -r "%%s"' % (options.repozo_file_name, ' '.join(options.repozo_opts))
timestamp_file = open(options.timestamp_file_path, 'r') if options.recover:
timestamp = '' timestamp_file = open(options.timestamp_file_path, 'r')
read_line = ' ' timestamp = ''
while len(read_line): read_line = ' '
timestamp = read_line while len(read_line):
read_line = timestamp_file.readline() timestamp = read_line
timestamp = timestamp.strip('\r\n \t') read_line = timestamp_file.readline()
if timestamp is not None: timestamp = timestamp.strip('\r\n \t')
repozo_formated_command += ' -o "%%s" -D %s' % (timestamp, ) if timestamp is not None:
result = recover( repozo_formated_command += ' -o "%%s" -D %s' % (timestamp, )
known_tid_storage_identifier_dict=options.known_tid_storage_identifier_dict, result = recover(
repozo_formated_command=repozo_formated_command, known_tid_storage_identifier_dict=options.known_tid_storage_identifier_dict,
check=options.dry_run) repozo_formated_command=repozo_formated_command,
else: check=options.dry_run)
repozo_formated_command += ' -f "%s" -m "%s"' else:
result = backup( repozo_formated_command += ' -f "%s" -m "%s"'
address=address, result = backup(
known_tid_storage_identifier_dict=options.known_tid_storage_identifier_dict, address=address,
zope_formated_url=zope_formated_url, known_tid_storage_identifier_dict=options.known_tid_storage_identifier_dict,
repozo_formated_command=repozo_formated_command) zope_formated_url=zope_formated_url,
if result == 0: repozo_formated_command=repozo_formated_command)
# Paranoid mode: if result == 0:
# Issue a system-wide "sync" command to make sure all files which were saved # Paranoid mode:
# are really present on disk. # Issue a system-wide "sync" command to make sure all files which were saved
os.system('sync') # are really present on disk.
timestamp_file = open(options.timestamp_file_path, 'a', 0) os.system('sync')
try: timestamp_file = open(options.timestamp_file_path, 'a', 0)
# Borrowed from repozo. try:
timestamp_file.write('\n%04d-%02d-%02d-%02d-%02d-%02d' % time.gmtime()[:6]) # Borrowed from repozo.
finally: timestamp_file.write('\n%04d-%02d-%02d-%02d-%02d-%02d' % time.gmtime()[:6])
timestamp_file.close() finally:
timestamp_file.close()
sys.exit(result) return result
if __name__ == '__main__':
sys.exit(main())
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment