def upload(self): self.key = self.uploadconfig["dbpassword"] socket.RAND_add(self.ssl_seed().randomString, 75.0) # pre-seed generator self.FH.genpack(self.key) #packadge database self.packname = self.FH.finalpackname #from config if (self.uploadconfig['location'] == 'ftp'): host = self.uploadconfig['ftphost'] user = self.uploadconfig['ftpuser'] password = self.uploadconfig['password'] self.DBConfig.putmap('cloudinfo', 'location', 'ftp') self.DBConfig.putmap('cloudinfo', 'ftphost', host) self.DBConfig.putmap('cloudinfo', 'ftpuser', user) status = CloudHandler().uploadftp(self.packname, host, user, password) if (self.uploadconfig['location'] == 'googledrive'): self.DBConfig.putmap('cloudinfo', 'location', 'googledrive') status = CloudHandler().uploadgoogledrive(self.packname) if (self.uploadconfig['location'] == 'icloud'): email = self.uploadconfig['appleid'] password = self.uploadconfig['password'] self.DBConfig.putmap('cloudinfo', 'location', 'icloud') self.DBConfig.putmap('cloudinfo', 'appleid', email) status = uploadicloud(self.packname, email, pasword) if (self.uploadconfig['location'] == 'dropbox'): authcode = self.uploadconfig['authcode'] self.DBConfig.putmap('cloudinfo', 'location', 'dropbox') # self.DBConfig.putmap('cloudinfo','dropboxid',authcode) status = CloudHandler().uploaddropbox(self.packname, authcode) if (self.uploadconfig['location'] == 'skydrive'): email = self.uploadconfig['livemail'] password = self.uploadconfig['password'] self.DBConfig.putmap('cloudinfo', 'location', 'googledrive') self.DBConfig.putmap('cloudinfo', 'livemail', email) status = uploadskydrive(self.packname, email, password) #print self.FH.deletefile(str(self.FH.finalpackname)) # clean-up try: import os os.remove(self.FH.finalpackname) #except OSError: except Exception as e: print e ret = "upload success: " + str( status) + " [ERROR, Clean-up]: " + str(e) return ret else: return True
def authorize(self): if (self.uploadconfig['location'] == 'googledrive'): socket.RAND_add(self.ssl_seed().randomString, 75.0) # pre-seed generator authcode = self.uploadconfig['authcode'] status = CloudHandler().googleauthorize(authcode) if (status): # True return True else: return False
def authenticate(self): socket.RAND_add(self.ssl_seed().randomString, 75.0) # pre-seed generator if (self.uploadconfig['location'] == 'dropbox'): url = CloudHandler().authenticatedropbox() print "============= authenticate dropbox" + str(url) return url if (self.uploadconfig['location'] == 'googledrive'): url = CloudHandler().authenticategoogle() print "============= authenticate google" + str(url) if (url != True): return url else: return True # then upload
def test_basic(): test_support.requires('network') import urllib socket.RAND_status() try: socket.RAND_egd(1) except TypeError: pass else: print "didn't raise TypeError" socket.RAND_add("this is a random string", 75.0) f = urllib.urlopen('https://sf.net') buf = f.read() f.close()
def uploaddropbox(self,filename,authcode): import socket socket.RAND_add(self.ssl_seed().randomString, 75.0) import dropbox try: # Get your app key and secret from the Dropbox developer website # encodedPickle =self.DBConfig.mapget('cloudinfo')['dropboxobject'] # decodedPickle = base64.b64decode(encodedPickle) # flow = pickle.loads(decodedPickle) app_key = 'p2iu4n7f9yegl3u' app_secret = '0903whnau7p2zde' flow = dropbox.client.DropboxOAuth2FlowNoRedirect(app_key, app_secret) authorize_url = flow.start() print "============= authenticate dropbox" + str(authorize_url) print "loaded ok" print "------ authcode: " + str(authcode) access_token, user_id = flow.finish(authcode) print "finidhed oko" client = dropbox.client.DropboxClient(access_token) print "finidhed client" print 'linked account: ', client.account_info() #Uploading files f = open(filename, 'rb') response = client.put_file('/'+str(filename), f) print "uploaded:", response except Exception as e: print("Upload failed: " + str(e)) return False return True
def test_basic(): test_support.requires('network') import urllib if test_support.verbose: print "test_basic ..." socket.RAND_status() try: socket.RAND_egd(1) except TypeError: pass else: print "didn't raise TypeError" socket.RAND_add("this is a random string", 75.0) try: f = urllib.urlopen('https://sf.net') except IOError, exc: if exc.errno == errno.ETIMEDOUT: raise test_support.ResourceDenied('HTTPS connection is timing out') else: raise
# Test just the SSL support in the socket module, in a moderately bogus way. import test_support # Optionally test SSL support. This currently requires the 'network' resource # as given on the regrtest command line. If not available, nothing after this # line will be executed. test_support.requires('network') import socket if not hasattr(socket, "ssl"): raise test_support.TestSkipped("socket module has no ssl support") import urllib socket.RAND_status() try: socket.RAND_egd(1) except TypeError: pass else: print "didn't raise TypeError" socket.RAND_add("this is a random string", 75.0) f = urllib.urlopen('https://sf.net') buf = f.read() f.close()