Skip to content

Commit

Permalink
Fix clean remote and temporary folder
Browse files Browse the repository at this point in the history
  • Loading branch information
quanpan302 committed Mar 3, 2020
1 parent ce0f2c9 commit 94344b7
Show file tree
Hide file tree
Showing 29 changed files with 261 additions and 116 deletions.
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/ESA/GLEAM.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,15 +588,20 @@ def convert_data(args):
latlim[1] + pixel_size, 0, -pixel_size]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/EU/JRC.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,15 +622,20 @@ def convert_data(args):
latmerge[1] - geo_trans[5] / 2., 0, geo_trans[5]]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/IHE/ALEXI.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,15 +628,20 @@ def convert_data(args):
geo = [lonlim[0], pixel_size, 0, latlim[1], 0, -pixel_size]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/IHE/CMRSET.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,15 +545,20 @@ def convert_data(args):
geo = [lonlim[0], pixel_size, 0, latlim[1], 0, -pixel_size]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/IHE/ETmonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,15 +583,20 @@ def convert_data(args):
latmerge[1] - geo_trans[5] / 2., 0, geo_trans[5]]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/IHE/HiHydroSoil.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,15 +546,20 @@ def convert_data(args):
latlim[1] + pixel_size / 2., 0, -pixel_size]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/IHE/SEBS.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,15 +546,20 @@ def convert_data(args):
geo = [lonlim[0], pixel_size, 0, latlim[1], 0, -pixel_size]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/IHE/TWC.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,15 +546,20 @@ def convert_data(args):
latlim[1] + pixel_size / 2., 0, -pixel_size]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/ISRIC/SoilGrids.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,15 +562,20 @@ def convert_data(args):
latmerge[1] - geo_trans[5] / 10., 0, geo_trans[5]]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/NASA/GLDAS.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,15 +586,20 @@ def convert_data(args):
latlim[1] + pixel_size / 10., 0, -pixel_size]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/NASA/GPM.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,15 +580,20 @@ def convert_data(args):
geo = [lonlim[0], pixel_size, 0, latlim[1], 0, -pixel_size]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/NASA/TRMM.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,15 +565,20 @@ def convert_data(args):
geo = [lonlim[0], pixel_size, 0, latlim[1], 0, -pixel_size]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/NOAA/CFSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,15 +599,20 @@ def convert_data(args):
geo = [lonlim[0], pixel_size, 0, latlim[1], 0, -pixel_size]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/NOAA/RFE.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,15 +558,20 @@ def convert_data(args):
geo = [lonlim[0], pixel_size, 0, latlim[1], 0, -pixel_size]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/USGS/CHIRPS.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,15 +557,20 @@ def convert_data(args):
geo = [lonlim[0], pixel_size, 0, latlim[1], 0, -pixel_size]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
13 changes: 9 additions & 4 deletions src/IHEWAcollect/templates/USGS/FEWS.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,15 +550,20 @@ def convert_data(args):
latlim[1], 0, -pixel_size]
Save_as_tiff(name=local_file, data=data, geo=geo, projection="WGS84")

clean(remote_file)
clean(temp_file)
path = os.path.dirname(os.path.realpath(remote_file))
if 'remote' != path[-6:]:
path = os.path.join(path, 'remote')
clean(path)
path = os.path.dirname(os.path.realpath(temp_file))
if 'temporary' != path[-9:]:
path = os.path.join(path, 'temporary')
clean(path)

status_cod = 0
return status_cod


def clean(file):
path = os.path.dirname(os.path.realpath(file))
def clean(path):
msg = 'Cleaning "{f}"'.format(f=path)
print('{}'.format(msg))
__this.Log.write(datetime.datetime.now(), msg=msg)
Expand Down
Loading

0 comments on commit 94344b7

Please sign in to comment.