Subprocess management: use a decorator

Use a decorator instead of a mixin to handle subprocess spawning and
monitoring
This commit is contained in:
gandalf3
2017-07-08 17:51:41 -07:00
parent fcf90a0e75
commit 1188f91b7b
5 changed files with 99 additions and 49 deletions

View File

@@ -1,8 +1,8 @@
#!/usr/bin/env python3
# HACK: seems 'requests' module bundled with blender isn't bundled with 'idna' module. So force system python for now
# import sys
# sys.path.insert(0, '/usr/lib/python3.6/site-packages')
import sys
sys.path.insert(0, '/usr/lib/python3.6/site-packages')
from pathlib import Path
import requests
@@ -56,10 +56,15 @@ class Repository:
req_headers = {}
# Do things this way to avoid adding empty objects/None to the req_headers dict
if 'etag' in self._headers:
req_headers['If-None-Match'] = self._headers['etag']
if 'last-modified' in self._headers:
req_headers['If-Modified-Since'] = self._headers['last-modified']
if self._headers:
try:
req_headers['If-None-Match'] = self._headers['etag']
except KeyError:
pass
try:
req_headers['If-Modified-Since'] = self._headers['last-modified']
except KeyError:
pass
#try
resp = requests.get(self.url, headers=req_headers)