def _testSendFile(properties): print('Testing sending single file...') thisfile = os.path.abspath(__file__) thispath,thisfilename = os.path.split(thisfile) try: sender = FTPSender(properties=properties,files=[thisfile]) sender.send() url = 'ftp://%s%s%s' % (properties['host'],properties['directory'],thisfilename) fh = urllib.request.urlopen(url) fh.close() sender.delete() except Exception as obj: fmt = 'Test failed - you may have a file called %s on host %s and directory %s' tpl = (thisfile,properties['host'],['directory']) raise ShakeMapException(fmt % tpl) print('Passed sending single file.')
def _testSendFile(properties): print('Testing sending single file...') thisfile = os.path.abspath(__file__) thispath, thisfilename = os.path.split(thisfile) try: sender = FTPSender(properties=properties, files=[thisfile]) sender.send() url = 'ftp://%s%s%s' % (properties['host'], properties['directory'], thisfilename) fh = urllib.request.urlopen(url) fh.close() sender.delete() except Exception as obj: fmt = 'Test failed - you may have a file called %s on host %s and directory %s' tpl = (thisfile, properties['host'], ['directory']) raise ShakeMapException(fmt % tpl) print('Passed sending single file.')
def _testSendFolder(properties): #modify this to create a temporary folder and send that - I think __pycache__ is screwing up the deletes... #although maybe I should test deleting directories with directories in them... print('Testing sending folder...') thisfile = os.path.abspath(__file__) thispath, thisfilename = os.path.split(thisfile) try: sender = FTPSender(properties=properties, directory=thispath) sender.send() url = 'ftp://%s%s' % (properties['host'], properties['directory']) fh = urllib.request.urlopen(url) fh.close() sender.delete() except Exception as obj: fmt = 'Test failed - you may have a file called %s on host %s and directory %s' tpl = (thisfile, properties['host'], ['directory']) raise ShakeMapException(fmt % tpl) print('Passed sending folder.')
def _testSendFolder(properties): #modify this to create a temporary folder and send that - I think __pycache__ is screwing up the deletes... #although maybe I should test deleting directories with directories in them... print('Testing sending folder...') thisfile = os.path.abspath(__file__) thispath,thisfilename = os.path.split(thisfile) try: sender = FTPSender(properties=properties,directory=thispath) sender.send() url = 'ftp://%s%s' % (properties['host'],properties['directory']) fh = urllib.request.urlopen(url) fh.close() sender.delete() except Exception as obj: fmt = 'Test failed - you may have a file called %s on host %s and directory %s' tpl = (thisfile,properties['host'],['directory']) raise ShakeMapException(fmt % tpl) print('Passed sending folder.')