if port is None: try: port = davitpy.rcParams['DB_PORT'] except: port = '22' estr = 'Config entry DB_PORT not set, using default' logging.info('{:s}: {:s}'.format(estr, port)) outdir = tmpdir # Now fetch the files temp = futils.fetch_remote_files(self.sTime, self.eTime, 'sftp', remote_site, remote_dirfmt, remote_dict, outdir, remote_fnamefmt, username=username, password=password, port=port) # check to see if the files actually have data between # stime and etime valid = self.__validate_fetched(temp, self.sTime, self.eTime) filelist = [x[0] for x in zip(temp, valid) if x[1]] invalid_files = [x[0] for x in zip(temp, valid) if not x[1]] if len(invalid_files) > 0: for f in invalid_files: estr = "removing invalid file: {:s}".format(f) logging.info(estr)
remote_fnamefmt = davitpy.rcParams['DAVIT_SD_REMOTE_FNAMEFMT'].split(',') except: remote_fnamefmt = ['{date}.{hemi}.{ftype}'] print 'Config entry DAVIT_SD_REMOTE_FNAMEFMT not set, using default:',remote_fnamefmt if port is None: try: port = davitpy.rcParams['DB_PORT'] except: port = '22' print 'Config entry DB_PORT not set, using default:',port outdir = tmpDir #Now fetch the files temp = fetch_remote_files(self.sTime, self.eTime, 'sftp', remote_site, \ remote_dirfmt, remote_dict, outdir, remote_fnamefmt, username=username, \ password=password, port=port, verbose=verbose) # check to see if the files actually have data between stime and etime valid = self.__validate_fetched(temp,self.sTime,self.eTime) filelist = [x[0] for x in zip(temp,valid) if x[1]] invalid_files = [x[0] for x in zip(temp,valid) if not x[1]] if len(invalid_files) > 0: for f in invalid_files: print 'removing invalid file: ' + f os.system('rm ' + f) # If we have valid files then continue if len(filelist) > 0 : print 'found',ftype,'data on sftp server'
from davitpy import pydarn from davitpy.pydarn.sdio.fetchUtils import fetch_remote_files print "##############################" print " TESTING THE DataPtr class..." print "##############################" stime = datetime.datetime(2012, 11, 24, 4) eTime = datetime.datetime(2012, 11, 24, 5) print " TRYING TO WORK WITH THE DMAP DATATYPE" print " FETCHING A SUPERDARN FITEX FILE......" files = fetch_remote_files(stime, eTime, \ 'sftp','sd-data.ece.vt.edu', 'data/{year}/{ftype}/{radar}/', \ {'radar':'mcm', 'ftype':'fitex', 'channel':'a'}, '/tmp/sd/', \ ['{date}.{hour}......{radar}.{ftype}', \ '{date}.{hour}......{radar}.{channel}.{ftype}'], \ username='******', password='******', \ time_inc=datetime.timedelta(hours=2)) print " Fetched the file: " + files[0] + "\n" print " INITIALIZING A CLASS THAT INHERITS FROM DataPtr" t = pydarn.sdio.DataTypes.testing(stime, 'dmap', eTime, files[0]) print " ...it worked! (Success!)" print " Opening the file..." t.open() print " ...it worked! (Success!)" print "Reading a line of the file..." dfile = t.read()
try: port = davitpy.rcParams['DB_PORT'] except: port = '22' estr = 'Config entry DB_PORT not set, using default' logging.info('{:s}: {:s}'.format(estr, port)) outdir = tmpdir # Now fetch the files temp = futils.fetch_remote_files(self.sTime, self.eTime, 'sftp', remote_site, remote_dirfmt, remote_dict, outdir, remote_fnamefmt, username=username, password=password, port=port) # check to see if the files actually have data between # stime and etime valid = self.__validate_fetched(temp, self.sTime, self.eTime) filelist = [x[0] for x in zip(temp, valid) if x[1]] invalid_files = [ x[0] for x in zip(temp, valid) if not x[1] ]
from davitpy.pydarn.sdio.fetchUtils import fetch_remote_files print "##############################" print " TESTING THE DataPtr class..." print "##############################" sTime = datetime.datetime(2012,11,24,4) eTime = datetime.datetime(2012,11,24,5) print " TRYING TO WORK WITH THE DMAP DATATYPE" print " FETCHING A SUPERDARN FITEX FILE......" files = fetch_remote_files(sTime, eTime, \ 'sftp','sd-data.ece.vt.edu','data/{year}/{ftype}/{radar}/', \ {'radar':'mcm','ftype':'fitex','channel':'a'},'/tmp/sd/', \ ['{date}.{hour}......{radar}.{ftype}', \ '{date}.{hour}......{radar}.{channel}.{ftype}'], \ username='******', password='******', \ verbose=False, time_inc=datetime.timedelta(hours=2)) print " Fetched the file: " + files[0] + "\n" print " INITIALIZING A CLASS THAT INHERITS FROM DataPtr" t=pydarn.sdio.DataTypes.testing(sTime,'dmap',eTime,files[0]) print " ...it worked! (Success!)" print " Opening the file..." t.open() print " ...it worked! (Success!)"