Advertisement
QuarkDoe

ocssw fix

Jan 20th, 2020
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. diff --git a/modules/ProcUtils.py b/modules/ProcUtils.py
  2. index edceb41..547fe7b 100644
  3. --- a/modules/ProcUtils.py
  4. +++ b/modules/ProcUtils.py
  5. @@ -6,7 +6,9 @@ SeaDAS library for commonly used functions within other python scripts
  6. from __future__ import print_function
  7.  
  8. import sys
  9. +import netrc
  10.  
  11. +netrc_dict=netrc.netrc()
  12.  
  13. # ------------------ DANGER -------------------
  14. #
  15. @@ -98,6 +100,7 @@ def _httpdl(url, request, localpath='.', outputfilename=None, ntries=5,
  16. verbose - get chatty about connection issues (boolean, default False)
  17. """
  18. global ofile
  19. + global netrc_dict
  20. import os
  21. import re
  22. import socket
  23. @@ -114,6 +117,13 @@ def _httpdl(url, request, localpath='.', outputfilename=None, ntries=5,
  24. os.umask(0o02)
  25. os.makedirs(localpath, mode=0o2775)
  26.  
  27. + cred=netrc_dict.authenticators(url)
  28. + if cred is not None:
  29. + from base64 import b64encode
  30. + ( _user, _acc, _pass ) = cred
  31. + userAndPass = b64encode(bytes(_user + ':' + _pass, "utf-8"))
  32. + reqHeaders.update({ 'Authorization' : 'Basic %s' % userAndPass })
  33. +
  34. urlConn, proxy = httpinit(url, timeout=timeout, urlConn=urlConn)
  35.  
  36. try:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement