fixes for Python 2 + color
This commit is contained in:
parent
0669808f19
commit
e8483f8c46
|
@ -206,7 +206,7 @@ class Buildozer(object):
|
||||||
color = COLOR_SEQ(LOG_LEVELS_C[level])
|
color = COLOR_SEQ(LOG_LEVELS_C[level])
|
||||||
print(''.join((RESET_SEQ, color, '# ', msg, RESET_SEQ)))
|
print(''.join((RESET_SEQ, color, '# ', msg, RESET_SEQ)))
|
||||||
else:
|
else:
|
||||||
print(LOG_LEVELS_T[level], msg)
|
print('{} {}'.format(LOG_LEVELS_T[level], msg))
|
||||||
|
|
||||||
def debug(self, msg):
|
def debug(self, msg):
|
||||||
self.log(2, msg)
|
self.log(2, msg)
|
||||||
|
|
|
@ -6,9 +6,11 @@ This is currently needed to correctly support db between Python 2 and 3.
|
||||||
__all__ = ["JsonStore"]
|
__all__ = ["JsonStore"]
|
||||||
|
|
||||||
import io
|
import io
|
||||||
from json import load, dump
|
import sys
|
||||||
|
from json import load, dump, dumps
|
||||||
from os.path import exists
|
from os.path import exists
|
||||||
|
|
||||||
|
IS_PY3 = sys.version_info[0] >= 3
|
||||||
|
|
||||||
class JsonStore(object):
|
class JsonStore(object):
|
||||||
|
|
||||||
|
@ -44,6 +46,11 @@ class JsonStore(object):
|
||||||
return self.data.keys()
|
return self.data.keys()
|
||||||
|
|
||||||
def sync(self):
|
def sync(self):
|
||||||
with io.open(self.filename, 'w', encoding='utf-8') as fd:
|
# http://stackoverflow.com/questions/12309269/write-json-data-to-file-in-python/14870531#14870531
|
||||||
dump(self.data, fd)
|
if IS_PY3:
|
||||||
|
with open(self.filename, 'w') as fd:
|
||||||
|
dump(self.data, fd, ensure_ascii=False)
|
||||||
|
else:
|
||||||
|
with io.open(self.filename, 'w', encoding='utf-8') as fd:
|
||||||
|
fd.write(unicode(dumps(self.data, ensure_ascii=False)))
|
||||||
|
|
||||||
|
|
|
@ -616,9 +616,9 @@ class TargetAndroid(Target):
|
||||||
# recreate the project.properties
|
# recreate the project.properties
|
||||||
with io.open(project_fn, 'w', encoding='utf-8') as fd:
|
with io.open(project_fn, 'w', encoding='utf-8') as fd:
|
||||||
for line in content:
|
for line in content:
|
||||||
fd.write(line)
|
fd.write(line.decode('utf-8'))
|
||||||
for index, ref in enumerate(references):
|
for index, ref in enumerate(references):
|
||||||
fd.write('android.library.reference.{}={}\n'.format(
|
fd.write(u'android.library.reference.{}={}\n'.format(
|
||||||
index + 1, ref))
|
index + 1, ref))
|
||||||
|
|
||||||
self.buildozer.debug('project.properties updated')
|
self.buildozer.debug('project.properties updated')
|
||||||
|
|
Loading…
Reference in a new issue