X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfa%2Fclient%2Fmanifolduploader.py;h=510382fd985642016661386ca56db7ef669992dd;hb=HEAD;hp=60bed0c31abc7d90d034ea9eca3af4fd66f380de;hpb=4948d60ec323588e00627eee303aa3859bba3c41;p=sfa.git diff --git a/sfa/client/manifolduploader.py b/sfa/client/manifolduploader.py index 60bed0c3..510382fd 100755 --- a/sfa/client/manifolduploader.py +++ b/sfa/client/manifolduploader.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # inspired from tophat/bin/uploadcredential.py # @@ -22,19 +22,14 @@ # so the defaults below are of no real importance # this for now points at demo.myslice.info, but sounds like a # better default for the long run -DEFAULT_URL = "http://myslice.onelab.eu:7080" -DEFAULT_PLATFORM = 'ple' +import getpass -# starting with 2.7.9 we need to turn off server verification -import ssl -try: - turn_off_server_verify = {'context': ssl._create_unverified_context()} -except: - turn_off_server_verify = {} +import xmlrpc.client -import getpass +from sfa.util.ssl import simple_ssl_context -from sfa.util.py23 import xmlrpc_client +DEFAULT_URL = "http://myslice.onelab.eu:7080" +DEFAULT_PLATFORM = 'ple' class ManifoldUploader: @@ -52,7 +47,7 @@ class ManifoldUploader: def username(self): if not self._username: - self._username = raw_input("Enter your manifold username: ") + self._username = input("Enter your manifold username: ") return self._username def password(self): @@ -64,7 +59,7 @@ class ManifoldUploader: def platform(self): if not self._platform: - self._platform = raw_input( + self._platform = input( "Enter your manifold platform [%s]: " % DEFAULT_PLATFORM) if self._platform.strip() == "": self._platform = DEFAULT_PLATFORM @@ -72,7 +67,7 @@ class ManifoldUploader: def url(self): if not self._url: - self._url = raw_input( + self._url = input( "Enter the URL for your manifold API [%s]: " % DEFAULT_URL) if self._url.strip() == "": self._url = DEFAULT_URL @@ -88,17 +83,10 @@ class ManifoldUploader: # won't be happy with several calls issued in the same session # so we do not cache this one def proxy(self): - # if not self._proxy: - # url=self.url() - # self.logger.info("Connecting manifold url %s"%url) - # self._proxy = xmlrpc_client.ServerProxy(url, allow_none = True) - # return self._proxy url = self.url() self.logger.debug("Connecting manifold url %s" % url) - proxy = xmlrpc_client.ServerProxy(url, allow_none=True, - **turn_off_server_verify) - - return proxy + return xmlrpc.client.ServerProxy(url, allow_none=True, + context=simple_ssl_context()) # does the job for one credential # expects the credential (string) and an optional message (e.g. hrn) for reporting @@ -146,7 +134,7 @@ class ManifoldUploader: self.logger.info(" V2 Update returned code %s and error >>%s<<" % ( retcod2['code'], retcod2['description'])) self.logger.debug("****** full retcod2") - for k, v in retcod2.items(): + for k, v in list(retcod2.items()): self.logger.debug("**** %s: %s" % (k, v)) return False except Exception as e: