commit 2337d9a6687fe50d5c2f4faf3d78d69627a556f7
parent 649da73e3caecde32a399413f1d05b10803a0fe2
Author: Marcel <MTRNord@users.noreply.github.com>
Date: Sun, 13 Nov 2016 11:53:59 +0100
Fixes for python3
Diffstat:
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/__init__.py b/__init__.py
@@ -6,6 +6,8 @@ import subprocess
import plugins
import re
from asyncio import subprocess
+from shutil import move
+from os import remove, close
logger = logging.getLogger(__name__)
@@ -23,12 +25,11 @@ def _open_file(name):
@asyncio.coroutine
def _replace(file_path, pattern, subst):
#Create temp file
- fh, abs_path = mkstemp()
+ abs_path = tempfile.NamedTemporaryFile(suffix=".js", delete=False).name
with open(abs_path,'w') as new_file:
with open(file_path) as old_file:
for line in old_file:
new_file.write(line.replace(pattern, subst))
- close(fh)
#Remove original file
remove(file_path)
#Move new file
@@ -36,9 +37,6 @@ def _replace(file_path, pattern, subst):
def _parse_onlineRepos(url, ext=''):
logger.debug("parsing github or gitlab or http(s)")
- headers = {
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36'
- }
page = requests.get(url, headers=headers).text
if 'gitlab.com' in url:
files = []