SHARE
TWEET

Untitled

a guest Jun 15th, 2017 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if __name__ == "__main__":
  2.     config = ConfigParser()
  3.    
  4.     translation = gettext.translation("pyLoadCli", join(pypath, "locale"), languages=["en", config['general']['language']])
  5.     translation.install(unicode=True)
  6.  
  7.     server_url = ""
  8.     username = ""
  9.     password = ""
  10.     addr = ""
  11.     port = ""
  12.     ssl = None
  13.  
  14.     add = ""
  15.  
  16.     if len(sys.argv) > 1:
  17.  
  18.  
  19.         addr = "127.0.0.1"
  20.         port = "7272"
  21.         ssl = ""
  22.  
  23.         shortOptions = 'lu:a:p:s:h'
  24.         longOptions = ['local', "username=", "address=", "port=", "ssl=", "help", "linklist=", "pw=", "configdir="]
  25.  
  26.         try:
  27.             opts, extraparams = getopt(sys.argv[1:], shortOptions, longOptions)
  28.             for option, params in opts:
  29.                 if option in ("-l", "--local"):
  30.  
  31.                     if config['ssl']['activated']:
  32.                         ssl = "s"
  33.  
  34.                     username = config.username
  35.                     password = config.password
  36.                     addr = config['remote']['listenaddr']
  37.                     port = config['remote']['port']
  38.                 elif option in ("-u", "--username"):
  39.                     username = params
  40.                 elif option in ("-a", "--address"):
  41.                     addr = params
  42.                 elif option in ("-p", "--port"):
  43.                     port = params
  44.                 elif option in ("-s", "--ssl"):
  45.                     if params.lower() == "true":
  46.                         ssl = "s"
  47.                 elif option in ("-h", "--help"):
  48.                     print_help()
  49.                     exit()
  50.                 elif option in ("--linklist"):
  51.                     add = params
  52.                 elif option in ("--pw"):
  53.                     password = params
  54.                 #####################################
  55.                 elif option in ("-c"):
  56.                     command = params
  57.                 #####################################
  58.         except GetoptError:
  59.             print 'Unknown Argument(s) "%s"' % " ".join(sys.argv[1:])
  60.             print_help()
  61.             exit()
  62.  
  63.         if len(extraparams) == 1:
  64.             server_url = sys.argv[1]
  65.  
  66.     if not server_url:
  67.         if not username: username = raw_input(_("Username: "))
  68.         if not addr: addr = raw_input(_("address: "))
  69.         if ssl is None:
  70.             ssl = raw_input(_("Use SSL? ([y]/n): "))
  71.             if ssl == "y" or ssl == "":
  72.                 ssl = "s"
  73.             else:
  74.                 ssl = ""
  75.         if not port: port = raw_input(_("Port: "))
  76.         if not password:
  77.             from getpass import getpass
  78.             password = getpass(_("Password: "))
  79.  
  80.         server_url = "http%s://%s:%s@%s:%s/" % (ssl, username, password, addr, port)
  81.     if command:
  82.         if command == "pause":
  83.             core.pause_server()
  84.         elif command == "unpause":
  85.             core.unpause_server()
  86.         elif command == "kill":
  87.             core.kill()
  88.             exit()
  89.         elif command == "queue":
  90.             data = core.status_downloads()
  91.             for download in data:
  92.                 print "%5d %s %s" % (int(download['id']),download['status'].rjust(8),download['name'])
  93.             exit()
  94.         elif command == "toggle":
  95.             if core.status_server()['pause']:
  96.                 core.unpause_server()
  97.             else:
  98.                 core.pause_server()
  99.         else:
  100.             print "Unknown Command"
  101.             print "Use one of:"
  102.             print "status        prints server status"
  103.             print "queue        prints download queue"
  104.             print "pause             pause the server"
  105.             print "unpause         continue downloads"
  106.             print "toggle        toggle pause/unpause"
  107.             print "kill                   kill server"
  108.         data = core.status_downloads()
  109.         status = core.status_server()
  110.         #Ausgabe generieren
  111.         if status['pause']:
  112.             print 'Status: paused'
  113.         else:
  114.             print 'Status: running'
  115.         print '%s Downloads' % len(data)
  116.         for download in data:
  117.             if download["status"] == 12: #downloading
  118.                 print 'Currently: %s %s\% @%s' % (download["name"],
  119.                     download['percent'], download['speed'])
  120.         exit()
  121.     if add:
  122.         cli = pyLoadCli(server_url, add)
  123.     else:
  124.         cli = pyLoadCli(server_url)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top