def backup_schedule_format(): """ See ``p2p.help.schedule_format()`` method. """ try: import help return help.schedule_format() except: return ''
def run(opts, args, overDict, pars): """ The entry point, this is called from `p2p.dhnmain` to process command line arguments. """ print 'Copyright 2006, DataHaven.NET LTD. of Anguilla. All rights reserved.' if overDict: settings.override_dict(overDict) dhnio.init() settings.init() if not opts or opts.debug is None: dhnio.SetDebug(0) appList = dhnio.find_process([ 'dhnmain.exe', 'dhnmain.py', 'dhn.py', 'regexp:^/usr/bin/python\ +/usr/bin/datahaven.*$', ]) running = len(appList) > 0 cmd = '' if len(args) > 0: cmd = args[0].lower() #---help--- if cmd in ['help', 'h']: import help if len(args) >= 2 and args[1].lower() == 'schedule': print help.schedule_format() elif len(args) >= 2 and args[1].lower() == 'settings': print settings.uconfig().print_all() else: print help.help() print pars.format_option_help() return 0 #---backup--- elif cmd in ['backup', 'backups', 'bk']: if not running: print 'DataHaven.NET is not running at the moment\n' return 0 return cmd_backups(opts, args, overDict) #---restore--- elif cmd in ['restore', 're']: if not running: print 'DataHaven.NET is not running at the moment\n' return 0 return cmd_restore(opts, args, overDict) #---schedule--- elif cmd in ['schedule', 'shed', 'sched', 'sh']: if not running: print 'DataHaven.NET is not running at the moment\n' return 0 return cmd_schedule(opts, args, overDict) #---suppliers--- elif cmd in [ 'suppliers', 'supplier', 'sup', 'supp', 'sp', ]: if not running: print 'DataHaven.NET is not running at the moment\n' return 0 return cmd_suppliers(opts, args, overDict) #---customers--- elif cmd in [ 'customers', 'customer', 'cus', 'cust', 'cs', ]: if not running: print 'DataHaven.NET is not running at the moment\n' return 0 return cmd_customers(opts, args, overDict) #---register--- elif cmd == 'register': if running: print 'DataHaven.NET already started.\n' return 0 return cmd_register(opts, args, overDict) #---recover--- elif cmd == 'recover': if running: print 'DataHaven.NET already started.\n' return 0 return cmd_recover(opts, args, overDict) #---key--- elif cmd == 'key': return cmd_key(opts, args, overDict) #---stats--- elif cmd in [ 'stats', 'st' ]: if not running: print 'DataHaven.NET is not running at the moment\n' return 0 return cmd_stats(opts, args, overDict) #---version--- elif cmd in [ 'version', 'v', 'ver' ]: revnum = dhnio.ReadTextFile(settings.RevisionNumberFile()).strip() repo, location = misc.ReadRepoLocation() print 'revision: ', revnum print 'repository:', repo return 0 #---states--- elif cmd in [ 'states', 'sta', 'automats', 'auto' ]: if not running: print 'DataHaven.NET is not running at the moment\n' return 0 return cmd_states(opts, args, overDict) #---reconnect--- elif cmd in [ 'reconnect', ]: if not running: print 'DataHaven.NET is not running at the moment\n' return 0 return cmd_reconnect(opts, args, overDict) #---set--- elif cmd == 'set': if len(args) == 1 or args[1].lower() in [ 'help', '?' ]: import help print help.settings_help() return 0 if not running: cmd_set_directly(opts, args, overDict) return 0 return cmd_set_request(opts, args, overDict) #---memory--- elif cmd == 'memory': if not running: print 'DataHaven.NET is not running at the moment\n' return 0 return cmd_memory(opts, args, overDict) #---money--- elif cmd == 'money': if not running: print 'DataHaven.NET is not running at the moment\n' return 0 return cmd_money(opts, args, overDict) elif cmd == 'storage': if not running: print 'DataHaven.NET is not running at the moment\n' return 0 return cmd_storage(opts, args, overDict) # elif cmd == 'uninstall': # return cmd_uninstall(opts, args, overDict) return 2