aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'pym/gentoolkit/revdep_rebuild')
-rw-r--r--pym/gentoolkit/revdep_rebuild/analyse.py3
-rw-r--r--pym/gentoolkit/revdep_rebuild/cache.py12
-rw-r--r--pym/gentoolkit/revdep_rebuild/collect.py8
-rw-r--r--pym/gentoolkit/revdep_rebuild/settings.py4
4 files changed, 18 insertions, 9 deletions
diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index c0e7231..0f89b03 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -8,6 +8,7 @@ import os
import re
import time
+from portage import _encodings, _unicode_decode, _unicode_encode
from portage.output import bold, blue, yellow, green
from .stuff import scan
@@ -82,7 +83,7 @@ def extract_dependencies_from_la(la, libraries, to_check, logger):
if not os.path.exists(_file):
continue
- for line in open(_file, 'r').readlines():
+ for line in open(_unicode_encode(_file), encoding=_encodings['fs'], mode='r').readlines():
line = line.strip()
if line.startswith('dependency_libs='):
match = re.match("dependency_libs='([^']+)'", line)
diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 3d925d8..31ee2c9 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -8,6 +8,7 @@ from __future__ import print_function
import os
import time
+from portage import _encodings, _unicode_decode, _unicode_encode
from portage.output import red
from .settings import DEFAULTS
@@ -29,7 +30,8 @@ def read_cache(temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
}
try:
for key,val in ret.items():
- _file = open(os.path.join(temp_path, key))
+ _file = open(_unicode_encode(os.path.join(temp_path, key)),
+ encoding=_encodings['fs'])
for line in _file.readlines():
val.add(line.strip())
#libraries.remove('\n')
@@ -52,12 +54,14 @@ def save_cache(logger, to_save={}, temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
os.makedirs(temp_path)
try:
- _file = open(os.path.join(temp_path, 'timestamp'), 'w')
+ _file = open(_unicode_encode(os.path.join(temp_path, 'timestamp')),
+ encoding=_encodings['fs'], mode='w')
_file.write(str(int(time.time())))
_file.close()
for key,val in to_save.items():
- _file = open(os.path.join(temp_path, key), 'w')
+ _file = open(_unicode_encode(os.path.join(temp_path, key)),
+ encoding=_encodings['fs'], mode='w')
for line in val:
_file.write(line + '\n')
_file.close()
@@ -85,7 +89,7 @@ def check_temp_files(temp_path=DEFAULTS['DEFAULT_TMP_DIR'], max_delay=3600,
return False
try:
- _file = open(timestamp_path)
+ _file = open(_unicode_encode(timestamp_path), encoding=_encodings['fs'])
timestamp = int(_file.readline())
_file .close()
except Exception as ex:
diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 2a431cb..758bcf7 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -11,6 +11,7 @@ import stat
import sys
import portage
+from portage import _encodings, _unicode_decode, _unicode_encode
from portage.output import blue, yellow
from .settings import parse_revdep_config
@@ -34,7 +35,7 @@ def parse_conf(conf_file, visited=None, logger=None):
for conf in conf_file:
try:
- with open(conf) as _file:
+ with open(_unicode_encode(conf), encoding=_encodings['fs']) as _file:
for line in _file.readlines():
line = line.strip()
if line.startswith('#'):
@@ -74,8 +75,9 @@ def prepare_search_dirs(logger, settings):
lib_dirs = set(['/lib', '/usr/lib', ])
#try:
- with open(os.path.join(
- portage.root, settings['DEFAULT_ENV_FILE']), 'r') as _file:
+ with open(_unicode_encode(os.path.join(
+ portage.root, settings['DEFAULT_ENV_FILE'])),
+ encoding=_encodings['fs'], mode='r') as _file:
for line in _file.readlines():
line = line.strip()
match = re.match("^export (ROOT)?PATH='([^']+)'", line)
diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index 08220f8..257bd3a 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -11,6 +11,7 @@ import re
import glob
import portage
+from portage import _encodings, _unicode_decode, _unicode_encode
DEFAULTS = {
'DEFAULT_LD_FILE': os.path.join(portage.root, 'etc/ld.so.conf'),
@@ -136,7 +137,8 @@ def parse_revdep_config(revdep_confdir):
masked_files = os.environ.get('LD_LIBRARY_MASK', '')
for _file in os.listdir(revdep_confdir):
- for line in open(os.path.join(revdep_confdir, _file)):
+ for line in open(_unicode_encode(os.path.join(revdep_confdir, _file)),
+ encoding=_encodings['fs']):
line = line.strip()
#first check for comment, we do not want to regex all lines
if not line.startswith('#'):