HotFix for SeaDAS 7.5 login problem
Posted: Wed Jan 22, 2020 1:24 am America/New_York
Hi!
This is my attempt to make hot fix for login problem.
I am not enough good with Python and internet protocols, so i decided to use external python library requests.
We are using Calculate Linux, so i don't know what the exactly package name in Ubuntu, RHL, or other non-gentoo-based distributions.
But i think it also can be installed though pip or pipenv
So this is last version of my fix. You also can donload it from Pastebin
How to use it:
1. Download it (or copy from this post) into some file. For example /tmp/seadas.diff
2. You should have installed GNU patch utility in your system.
3. Use command
4. ...
5. PROFIT!
In additional you can create local branch in git to prevent future conflicts with updates.
Any comments or improvements are welcome.
UPD. Made some changes for fix `UnboundLocalError: local variable 'status' referenced before assignment`
See in attachment.attachment 1
attachment 2
This is my attempt to make hot fix for login problem.
I am not enough good with Python and internet protocols, so i decided to use external python library requests.
We are using Calculate Linux, so i don't know what the exactly package name in Ubuntu, RHL, or other non-gentoo-based distributions.
But i think it also can be installed though pip or pipenv
So this is last version of my fix. You also can donload it from Pastebin
diff --git a/modules/ProcUtils.py b/modules/ProcUtils.py
index edceb41..7fb44f2 100644
--- a/modules/ProcUtils.py
+++ b/modules/ProcUtils.py
@@ -6,7 +6,7 @@ SeaDAS library for commonly used functions within other python scripts
from __future__ import print_function
import sys
-
+import requests
# ------------------ DANGER -------------------
#
@@ -251,9 +251,50 @@ def _httpdl(url, request, localpath='.', outputfilename=None, ntries=5,
def httpdl(url, request, localpath='.', outputfilename=None, ntries=5,
uncompress=False, timeout=30., reqHeaders={}, verbose=False,
reuseConn=False, urlConn=None, chunk_size=DEFAULT_CHUNK_SIZE):
- urlConn, status = _httpdl(url, request, localpath, outputfilename, ntries,
- uncompress, timeout, reqHeaders, verbose,
- reuseConn, urlConn, chunk_size)
+
+ import requests
+ import os
+ import re
+
+ if not os.path.exists(localpath):
+ os.umask(0o02)
+ os.makedirs(localpath, mode=0o2775)
+
+ r = requests.get("https://%s%s" % (url,request), stream=True)
+
+ if r.status_code == 200 or r.status_code == 206:
+
+ if outputfilename:
+ ofile = os.path.join(localpath, outputfilename)
+ else:
+ if 'content-disposition' in r.headers:
+ ofile = os.path.join(localpath, r.headers.get('content-disposition').split('filename=')[1] )
+ else:
+ ofile = os.path.join(localpath, os.path.basename(request))
+
+ if r.status_code == 200:
+ f = open(ofile, 'wb')
+ else:
+ f = open(ofile, 'ab')
+
+ for chunk in r.iter_content(chunk_size=chunk_size):
+ if chunk: # filter out keep-alive new chunks
+ f.write(chunk)
+
+ f.flush()
+
+ if re.search(".(Z|gz|bz2)$", ofile) and uncompress:
+ compressStatus = uncompressFile(ofile)
+ if compressStatus:
+ status = compressStatus
+ else:
+ status = 0
+ else:
+ status = r.status_code
+
+# urlConn, status = _httpdl(url, request, localpath, outputfilename, ntries,
+# uncompress, timeout, reqHeaders, verbose,
+# reuseConn, urlConn, chunk_size)
if reuseConn:
return (urlConn, status)
else:
How to use it:
1. Download it (or copy from this post) into some file. For example /tmp/seadas.diff
2. You should have installed GNU patch utility in your system.
3. Use command
patch -d ${OCSSWROOT}/scripts -p1 </tmp/seadas.diff
4. ...
5. PROFIT!
In additional you can create local branch in git to prevent future conflicts with updates.
Any comments or improvements are welcome.
UPD. Made some changes for fix `UnboundLocalError: local variable 'status' referenced before assignment`
See in attachment.attachment 1
attachment 2