Merge branch 'python3'
Conflicts: utils.py
This commit is contained in:
commit
32d59c9f00
11 changed files with 114 additions and 136 deletions
|
|
@ -19,4 +19,4 @@ rm Web2ExeLinux/files/error.log Web2ExeLinux/files/last_project_path.txt Web2Exe
|
|||
zip -r -9 Web2ExeLinux-CMD.zip Web2ExeLinux-CMD/*
|
||||
zip -r -9 Web2ExeLinux-${VERSION}.zip Web2ExeLinux
|
||||
|
||||
python upload_release.py
|
||||
python3.4 upload_release.py
|
||||
|
|
|
|||
114
command_line.py
114
command_line.py
|
|
@ -12,7 +12,7 @@ from pycns import save_icns
|
|||
from pepy.pe import PEFile
|
||||
|
||||
import argparse
|
||||
import urllib2
|
||||
import urllib.request as request
|
||||
import platform
|
||||
import re
|
||||
import time
|
||||
|
|
@ -40,10 +40,7 @@ from semantic_version import Version
|
|||
from zipfile import ZipFile
|
||||
from tarfile import TarFile
|
||||
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
except ImportError:
|
||||
from StringIO import StringIO
|
||||
from io import StringIO
|
||||
|
||||
from configobj import ConfigObj
|
||||
|
||||
|
|
@ -93,7 +90,7 @@ handler = lh.RotatingFileHandler(LOG_FILENAME, maxBytes=100000, backupCount=2)
|
|||
logger.addHandler(handler)
|
||||
|
||||
def my_excepthook(type_, value, tback):
|
||||
output_err = u''.join([unicode(x) for x in traceback.format_exception(type_, value, tback)])
|
||||
output_err = u''.join([x for x in traceback.format_exception(type_, value, tback)])
|
||||
logger.error(u'{}'.format(output_err))
|
||||
sys.__excepthook__(type_, value, tback)
|
||||
|
||||
|
|
@ -150,10 +147,10 @@ class Setting(object):
|
|||
self.get_file_information_from_url()
|
||||
|
||||
def filter_name(self, text):
|
||||
action = unicode
|
||||
if hasattr(unicode, self.filter_action):
|
||||
action = getattr(unicode, self.filter_action)
|
||||
return action(unicode(text))
|
||||
if hasattr(self.filter_action, text):
|
||||
action = getattr(self.filter_action, text)
|
||||
return action(text)
|
||||
return text
|
||||
|
||||
def get_file_information_from_url(self):
|
||||
if hasattr(self, 'url'):
|
||||
|
|
@ -256,9 +253,9 @@ class Setting(object):
|
|||
elif self.file_ext == '.zip':
|
||||
new_bytes = file.read(extract_p)
|
||||
except KeyError as e:
|
||||
logger.error(unicode(e))
|
||||
logger.error(str(e))
|
||||
# dirty hack to support old versions of nw
|
||||
if 'no item named' in unicode(e):
|
||||
if 'no item named' in str(e):
|
||||
extract_path = '/'.join(extract_path.split('/')[1:])
|
||||
try:
|
||||
if self.file_ext == '.gz':
|
||||
|
|
@ -266,7 +263,7 @@ class Setting(object):
|
|||
elif self.file_ext == '.zip':
|
||||
new_bytes = file.read(extract_path)
|
||||
except KeyError as e:
|
||||
logger.error(unicode(e))
|
||||
logger.error(str(e))
|
||||
|
||||
if new_bytes is not None:
|
||||
fbytes.append((dest_path, new_bytes))
|
||||
|
|
@ -335,7 +332,7 @@ class CommandBase(object):
|
|||
config_io = StringIO(contents)
|
||||
config = ConfigObj(config_io, unrepr=True).dict()
|
||||
settings = {'setting_groups': []}
|
||||
setting_items = (config['setting_groups'].items() +
|
||||
setting_items = (list(config['setting_groups'].items()) +
|
||||
[('export_settings', config['export_settings'])] +
|
||||
[('compression', config['compression'])])
|
||||
for setting_group, setting_group_dict in setting_items:
|
||||
|
|
@ -351,7 +348,7 @@ class CommandBase(object):
|
|||
for setting_group, setting_group_dict in sgroup_items:
|
||||
settings['setting_groups'].append(settings[setting_group])
|
||||
|
||||
self._setting_items = (config['setting_groups'].items() +
|
||||
self._setting_items = (list(config['setting_groups'].items()) +
|
||||
[('export_settings', config['export_settings'])] +
|
||||
[('compression', config['compression'])])
|
||||
config.pop('setting_groups')
|
||||
|
|
@ -405,8 +402,8 @@ class CommandBase(object):
|
|||
union_versions = set()
|
||||
|
||||
for url in self.settings['version_info']['urls']:
|
||||
response = urllib2.urlopen(url)
|
||||
html = response.read()
|
||||
response = request.urlopen(url)
|
||||
html = response.read().decode('utf-8')
|
||||
|
||||
nw_version = self.get_setting('nw_version')
|
||||
|
||||
|
|
@ -431,7 +428,7 @@ class CommandBase(object):
|
|||
f.write(v+os.linesep)
|
||||
f.close()
|
||||
except IOError:
|
||||
error = u''.join([unicode(x) for x in traceback.format_exception(sys.exc_info()[0],
|
||||
error = u''.join([x for x in traceback.format_exception(sys.exc_info()[0],
|
||||
sys.exc_info()[1],
|
||||
sys.exc_info()[2])])
|
||||
self.show_error(error)
|
||||
|
|
@ -458,7 +455,7 @@ class CommandBase(object):
|
|||
if os.path.exists(setting.save_file_path(version, location)):
|
||||
os.remove(setting.save_file_path(version, location))
|
||||
|
||||
error = u''.join([unicode(x) for x in traceback.format_exception(sys.exc_info()[0],
|
||||
error = u''.join([x for x in traceback.format_exception(sys.exc_info()[0],
|
||||
sys.exc_info()[1],
|
||||
sys.exc_info()[2])])
|
||||
self.show_error(error)
|
||||
|
|
@ -498,7 +495,7 @@ class CommandBase(object):
|
|||
if setting.value is not None:
|
||||
dic[setting_name] = setting.value
|
||||
if setting_name == 'keywords':
|
||||
dic[setting_name] = re.findall("\w+", setting.value)
|
||||
dic[setting_name] = re.findall('\w+', setting.value)
|
||||
|
||||
for setting_name, setting in self.settings['window_settings'].items():
|
||||
if setting.value is not None:
|
||||
|
|
@ -515,14 +512,14 @@ class CommandBase(object):
|
|||
dic['webkit'][setting_name] = setting.value
|
||||
|
||||
if not global_json:
|
||||
dl_export_items = (self.settings['download_settings'].items() +
|
||||
self.settings['export_settings'].items() +
|
||||
self.settings['compression'].items() +
|
||||
self.settings['web2exe_settings'].items())
|
||||
dl_export_items = (list(self.settings['download_settings'].items()) +
|
||||
list(self.settings['export_settings'].items()) +
|
||||
list(self.settings['compression'].items()) +
|
||||
list(self.settings['web2exe_settings'].items()))
|
||||
else:
|
||||
dl_export_items = (self.settings['download_settings'].items() +
|
||||
self.settings['export_settings'].items() +
|
||||
self.settings['compression'].items())
|
||||
dl_export_items = (list(self.settings['download_settings'].items()) +
|
||||
list(self.settings['export_settings'].items()) +
|
||||
list(self.settings['compression'].items()))
|
||||
|
||||
for setting_name, setting in dl_export_items:
|
||||
if setting.value is not None:
|
||||
|
|
@ -539,7 +536,7 @@ class CommandBase(object):
|
|||
@extract_error.setter
|
||||
def extract_error(self, value):
|
||||
if value is not None and not self.quiet and COMMAND_LINE:
|
||||
self._extract_error = unicode(value)
|
||||
self._extract_error = value
|
||||
sys.stderr.write(u'\r{}'.format(self._extract_error))
|
||||
sys.stderr.flush()
|
||||
|
||||
|
|
@ -550,7 +547,7 @@ class CommandBase(object):
|
|||
@output_err.setter
|
||||
def output_err(self, value):
|
||||
if value is not None and not self.quiet and COMMAND_LINE:
|
||||
self._output_err = unicode(value)
|
||||
self._output_err = value
|
||||
sys.stderr.write(u'\r{}'.format(self._output_err))
|
||||
sys.stderr.flush()
|
||||
|
||||
|
|
@ -561,7 +558,7 @@ class CommandBase(object):
|
|||
@progress_text.setter
|
||||
def progress_text(self, value):
|
||||
if value is not None and not self.quiet and COMMAND_LINE:
|
||||
self._progress_text = unicode(value)
|
||||
self._progress_text = value
|
||||
sys.stdout.write(u'\r{}'.format(self._progress_text))
|
||||
sys.stdout.flush()
|
||||
|
||||
|
|
@ -624,7 +621,7 @@ class CommandBase(object):
|
|||
if os.path.exists(save_file_path):
|
||||
os.remove(save_file_path)
|
||||
self.extract_error = e
|
||||
self.logger.error(unicode(self.extract_error))
|
||||
self.logger.error(self.extract_error)
|
||||
# cannot use GUI in thread to notify user. Save it for later
|
||||
self.progress_text = '\nDone.\n'
|
||||
return True
|
||||
|
|
@ -662,24 +659,12 @@ class CommandBase(object):
|
|||
|
||||
output_dir = utils.path_join(self.output_dir(), self.project_name())
|
||||
if os.path.exists(output_dir):
|
||||
try:
|
||||
utils.rmtree(output_dir)
|
||||
except OSError as e:
|
||||
error = u'Failed to remove output directory: {}.'.format(output_dir)
|
||||
error += '\nError recieved: {}'.format(e)
|
||||
self.logger.error(error)
|
||||
self.output_err += error
|
||||
utils.rmtree(output_dir, onerror=self.remove_readonly)
|
||||
|
||||
temp_dir = utils.path_join(TEMP_DIR, 'webexectemp')
|
||||
|
||||
if os.path.exists(temp_dir):
|
||||
try:
|
||||
utils.rmtree(temp_dir)
|
||||
except OSError as e:
|
||||
error = u'Failed to remove temporary directory: {}.'.format(temp_dir)
|
||||
error += '\nError recieved: {}'.format(e)
|
||||
self.logger.error(error)
|
||||
self.output_err += error
|
||||
utils.rmtree(temp_dir, onerror=self.remove_readonly)
|
||||
|
||||
self.progress_text = 'Making new directories...\n'
|
||||
|
||||
|
|
@ -814,19 +799,13 @@ class CommandBase(object):
|
|||
os.remove(nw_path)
|
||||
|
||||
except Exception:
|
||||
error = u''.join([unicode(x) for x in traceback.format_exception(sys.exc_info()[0],
|
||||
error = u''.join([x for x in traceback.format_exception(sys.exc_info()[0],
|
||||
sys.exc_info()[1],
|
||||
sys.exc_info()[2])])
|
||||
self.logger.error(error)
|
||||
self.output_err += error
|
||||
finally:
|
||||
try:
|
||||
utils.rmtree(temp_dir)
|
||||
except OSError as e:
|
||||
error = u'Failed to remove temporary directory: {}.'.format(temp_dir)
|
||||
error += '\nError recieved: {}'.format(e)
|
||||
self.logger.error(error)
|
||||
self.output_err += error
|
||||
utils.rmtree(temp_dir, onerror=self.remove_readonly)
|
||||
|
||||
def make_desktop_file(self, nw_path, export_dest):
|
||||
icon_set = self.get_setting('icon')
|
||||
|
|
@ -860,7 +839,7 @@ class CommandBase(object):
|
|||
with codecs.open(dfile_path, 'w+', encoding='utf-8') as f:
|
||||
f.write(file_str)
|
||||
|
||||
os.chmod(dfile_path, 0755)
|
||||
os.chmod(dfile_path, 0o755)
|
||||
|
||||
def compress_nw(self, nw_path):
|
||||
compression = self.get_setting('nw_compression_level')
|
||||
|
|
@ -884,8 +863,8 @@ class CommandBase(object):
|
|||
|
||||
if upx_version is not None:
|
||||
upx_bin = upx_version
|
||||
os.chmod(upx_bin, 0755)
|
||||
cmd = [upx_bin, '--lzma', u'-{}'.format(compression.value), unicode(nw_path)]
|
||||
os.chmod(upx_bin, 0o755)
|
||||
cmd = [upx_bin, '--lzma', u'-{}'.format(compression.value), nw_path]
|
||||
if platform.system() == 'Windows':
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
|
||||
|
|
@ -905,6 +884,16 @@ class CommandBase(object):
|
|||
time.sleep(2)
|
||||
output, err = proc.communicate()
|
||||
|
||||
def remove_readonly(self, action, name, exc):
|
||||
try:
|
||||
os.chmod(name, stat.S_IWRITE)
|
||||
os.remove(name)
|
||||
except Exception as e:
|
||||
error = u'Failed to remove file: {}.'.format(name)
|
||||
error += '\nError recieved: {}'.format(e)
|
||||
self.logger.error(error)
|
||||
self.output_err += error
|
||||
|
||||
def copy_files_to_project_folder(self):
|
||||
old_dir = CWD
|
||||
os.chdir(self.project_dir())
|
||||
|
|
@ -927,7 +916,7 @@ class CommandBase(object):
|
|||
def convert_val_to_str(self, val):
|
||||
if isinstance(val, (list, tuple)):
|
||||
return ', '.join(val)
|
||||
return unicode(val).replace(self.project_dir()+os.path.sep, '')
|
||||
return str(val).replace(self.project_dir()+os.path.sep, '')
|
||||
|
||||
|
||||
def run_script(self, script):
|
||||
|
|
@ -1115,9 +1104,9 @@ class CommandBase(object):
|
|||
elif tmp_exists and (os.stat(tmp_file).st_size > 0):
|
||||
tmp_size = os.stat(tmp_file).st_size
|
||||
headers = {'Range': 'bytes={}-'.format(tmp_size)}
|
||||
url = urllib2.Request(url, headers=headers)
|
||||
url = request.Request(url, headers=headers)
|
||||
|
||||
web_file = urllib2.urlopen(url)
|
||||
web_file = request.urlopen(url)
|
||||
f = open(tmp_file, 'ab')
|
||||
meta = web_file.info()
|
||||
file_size = tmp_size + int(meta.getheaders("Content-Length")[0])
|
||||
|
|
@ -1179,8 +1168,7 @@ class ArgParser(argparse.ArgumentParser):
|
|||
sys.exit(2)
|
||||
|
||||
def unicode_arg(bytestring):
|
||||
unicode_string = bytestring.decode(sys.getfilesystemencoding())
|
||||
return unicode_string
|
||||
return bytestring
|
||||
|
||||
def main():
|
||||
parser = ArgParser(description=('Command line interface '
|
||||
|
|
@ -1233,7 +1221,7 @@ def main():
|
|||
else:
|
||||
if setting.values:
|
||||
kwargs.update({'choices': setting.values})
|
||||
setting.description += u' Possible values: {{{}}}'.format(', '.join([unicode(x) for x in setting.values]))
|
||||
setting.description += u' Possible values: {{{}}}'.format(', '.join([str(x) for x in setting.values]))
|
||||
kwargs.update({'metavar': ''})
|
||||
else:
|
||||
kwargs.update({'metavar': '<{}>'.format(setting.display_name)})
|
||||
|
|
@ -1276,7 +1264,7 @@ def main():
|
|||
logger.addHandler(handler)
|
||||
|
||||
def my_excepthook(type_, value, tback):
|
||||
output_err = u''.join([unicode(x) for x in traceback.format_exception(type_, value, tback)])
|
||||
output_err = u''.join([x for x in traceback.format_exception(type_, value, tback)])
|
||||
logger.error(u'{}'.format(output_err))
|
||||
sys.__excepthook__(type_, value, tback)
|
||||
|
||||
|
|
|
|||
31
icns_info.py
31
icns_info.py
|
|
@ -3,7 +3,7 @@ import image_utils
|
|||
import png
|
||||
from PIL import Image
|
||||
import os
|
||||
from cStringIO import StringIO
|
||||
from io import BytesIO
|
||||
|
||||
#---------------------CONSTANTS-----------------------------------------------#
|
||||
|
||||
|
|
@ -406,13 +406,13 @@ def encode_rle24(data):
|
|||
if len(data) >= 65536:
|
||||
dataTempCount = 4
|
||||
|
||||
for colorOffset in xrange(3):
|
||||
for colorOffset in range(3):
|
||||
runCount = 0
|
||||
runLength = 1
|
||||
runType = 0
|
||||
dataRun[0] = data[colorOffset]
|
||||
|
||||
for dataInCount in xrange(1, dataInChanSize):
|
||||
for dataInCount in range(1, dataInChanSize):
|
||||
dataByte = data[colorOffset+(dataInCount*4)]
|
||||
if runLength < 2:
|
||||
dataRun[runLength] = dataByte
|
||||
|
|
@ -588,7 +588,7 @@ def to_bytes(n, length, endianess='big'):
|
|||
def from_bytes(byte_str):
|
||||
bits = (len(byte_str)-1)*8
|
||||
result = 0
|
||||
for i in xrange(len(byte_str)):
|
||||
for i in range(len(byte_str)):
|
||||
result = (byte_str[i] << bits) + result
|
||||
bits -= 8
|
||||
return result
|
||||
|
|
@ -625,12 +625,9 @@ class Printable(object):
|
|||
return u', '.join(vals)
|
||||
|
||||
def __repr__(self):
|
||||
return unicode(self)
|
||||
return str(self)
|
||||
|
||||
def __str__(self):
|
||||
return unicode(self).encode('utf-8')
|
||||
|
||||
def __unicode__(self):
|
||||
return u'{} [{}]'.format(self.__class__.__name__, self._dict_string())
|
||||
|
||||
|
||||
|
|
@ -953,7 +950,7 @@ class ICNSInfo(Printable):
|
|||
icon_info.iconPixelDepth = 1
|
||||
icon_info.iconBitDepth = 1
|
||||
else:
|
||||
print 'Unable to parse icon type {}'.format(type_to_str(type))
|
||||
print('Unable to parse icon type {}'.format(type_to_str(type)))
|
||||
icon_info.iconType = ICNS_NULL_TYPE
|
||||
|
||||
icon_info.iconRawDataSize = icon_info.iconSize.height * icon_info.iconSize.width * icon_info.iconBitDepth/ICNS_BYTE_BITS
|
||||
|
|
@ -1112,9 +1109,9 @@ class ICNSElement(Structure):
|
|||
icns_info.iconRawDataSize = width * height * 4
|
||||
icns_info.data = bytearray(list(png_data))
|
||||
else:
|
||||
image = Image.open(StringIO(data))
|
||||
image = Image.open(BytesIO(data))
|
||||
mode_to_bpp = {'1':1, 'L':8, 'P':8, 'RGB':24, 'RGBA':32, 'CMYK':32, 'YCbCr':24, 'I':32, 'F':32}
|
||||
output = StringIO()
|
||||
output = BytesIO()
|
||||
image.save(output, format='PNG')
|
||||
bpp = mode_to_bpp[image.mode]
|
||||
png_data = bytearray(output.getvalue())
|
||||
|
|
@ -1291,7 +1288,7 @@ def get_image_with_mask(icns_data, element_type):
|
|||
ICNS_32x32_8BIT_DATA,
|
||||
ICNS_16x16_8BIT_DATA,
|
||||
ICNS_16x12_8BIT_DATA]:
|
||||
for pixel_id in xrange(pixel_count):
|
||||
for pixel_id in range(pixel_count):
|
||||
color_index = old_data[data_count]
|
||||
color_rgb = icns_colormap_8[color_index]
|
||||
new_data[pixel_id*4+0] = color_rgb[0]
|
||||
|
|
@ -1304,7 +1301,7 @@ def get_image_with_mask(icns_data, element_type):
|
|||
ICNS_16x16_4BIT_DATA,
|
||||
ICNS_16x12_4BIT_DATA]:
|
||||
data_value = 0
|
||||
for pixel_id in xrange(pixel_count):
|
||||
for pixel_id in range(pixel_count):
|
||||
if (pixel_id % 2) == 0:
|
||||
data_value = old_data[data_count]
|
||||
data_count += 1
|
||||
|
|
@ -1319,7 +1316,7 @@ def get_image_with_mask(icns_data, element_type):
|
|||
ICNS_16x16_1BIT_DATA,
|
||||
ICNS_16x12_1BIT_DATA]:
|
||||
data_value = 0
|
||||
for pixel_id in xrange(pixel_count):
|
||||
for pixel_id in range(pixel_count):
|
||||
if (pixel_id % 8) == 0:
|
||||
data_value = old_data[data_count]
|
||||
data_count += 1
|
||||
|
|
@ -1341,7 +1338,7 @@ def get_image_with_mask(icns_data, element_type):
|
|||
ICNS_16x16_8BIT_MASK]:
|
||||
pixel_count = mask_image.iconSize.width * mask_image.iconSize.height
|
||||
data_count = 0
|
||||
for pixel_id in xrange(pixel_count):
|
||||
for pixel_id in range(pixel_count):
|
||||
icns_image.data[pixel_id*4+3] = mask_image.data[data_count]
|
||||
data_count += 1
|
||||
|
||||
|
|
@ -1352,7 +1349,7 @@ def get_image_with_mask(icns_data, element_type):
|
|||
pixel_count = mask_image.iconSize.width * mask_image.iconSize.height
|
||||
data_count = 0
|
||||
data_value = 0
|
||||
for pixel_id in xrange(pixel_count):
|
||||
for pixel_id in range(pixel_count):
|
||||
if (pixel_id % 8) == 0:
|
||||
data_value = mask_image.data[data_count]
|
||||
data_count += 1
|
||||
|
|
@ -1360,7 +1357,7 @@ def get_image_with_mask(icns_data, element_type):
|
|||
data_value = data_value << 1
|
||||
icns_image.data[pixel_id*4+3] = color_index
|
||||
im = Image.frombytes('RGBA', [icns_image.iconSize.width,icns_image.iconSize.height],str(icns_image.data))
|
||||
output = StringIO()
|
||||
output = BytesIO()
|
||||
im.save(output, format='PNG')
|
||||
icns_image.data = bytearray(output.getvalue())
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
from cStringIO import StringIO
|
||||
from io import BytesIO
|
||||
try:
|
||||
from PIL import Image as im
|
||||
IMAGE_UTILS_AVAILABLE = True
|
||||
Image = im.open
|
||||
def resize(image, size):
|
||||
output = StringIO()
|
||||
output = BytesIO()
|
||||
back = im.new('RGBA', size, (0,0,0,0))
|
||||
image.thumbnail(size, im.ANTIALIAS)
|
||||
offset = [0,0]
|
||||
|
|
@ -32,7 +32,7 @@ def nearest_icon_size(width, height):
|
|||
if maximum <= SMALLEST_ICON_SIZE:
|
||||
return SMALLEST_ICON_SIZE
|
||||
|
||||
for i in xrange(len(sizes)-1):
|
||||
for i in range(len(sizes)-1):
|
||||
current_size = sizes[i]
|
||||
next_size = sizes[i+1]
|
||||
if current_size > maximum >= next_size:
|
||||
|
|
|
|||
42
main.py
42
main.py
|
|
@ -48,7 +48,7 @@ class ExistingProjectDialog(QtGui.QDialog):
|
|||
|
||||
self.projects = recent_projects
|
||||
|
||||
for i in xrange(len(recent_projects)):
|
||||
for i in range(len(recent_projects)):
|
||||
project = recent_projects[i]
|
||||
text = u'{} - {}'.format(os.path.basename(project), project)
|
||||
self.project_list.addItem(text)
|
||||
|
|
@ -104,9 +104,9 @@ class ExistingProjectDialog(QtGui.QDialog):
|
|||
class Validator(QtGui.QRegExpValidator):
|
||||
def __init__(self, regex, action, parent=None):
|
||||
self.exp = regex
|
||||
self.action = unicode
|
||||
if hasattr(unicode, action):
|
||||
self.action = getattr(unicode, action)
|
||||
self.action = str
|
||||
if hasattr(str, action):
|
||||
self.action = getattr(str, action)
|
||||
reg = QtCore.QRegExp(regex)
|
||||
super(Validator, self).__init__(reg, parent)
|
||||
|
||||
|
|
@ -115,7 +115,7 @@ class Validator(QtGui.QRegExpValidator):
|
|||
return result
|
||||
|
||||
def fixup(self, text):
|
||||
return ''.join(re.findall(self.exp, self.action(unicode(text))))
|
||||
return ''.join(re.findall(self.exp, self.action(text)))
|
||||
|
||||
|
||||
class BackgroundThread(QtCore.QThread):
|
||||
|
|
@ -184,7 +184,7 @@ class MainWindow(QtGui.QMainWindow, CommandBase):
|
|||
def update_recent_files(self):
|
||||
previous_files = self.load_recent_projects()
|
||||
self.recent_separator.setVisible(len(previous_files) > 0)
|
||||
for i in xrange(len(previous_files)):
|
||||
for i in range(len(previous_files)):
|
||||
text = u'{} - {}'.format(i+1, os.path.basename(previous_files[i]))
|
||||
action = self.recent_file_actions[i]
|
||||
action.setText(text)
|
||||
|
|
@ -223,7 +223,7 @@ class MainWindow(QtGui.QMainWindow, CommandBase):
|
|||
|
||||
self.recent_file_actions = []
|
||||
|
||||
for i in xrange(MAX_RECENT):
|
||||
for i in range(MAX_RECENT):
|
||||
if i == 9:
|
||||
key = 0
|
||||
else:
|
||||
|
|
@ -381,7 +381,7 @@ class MainWindow(QtGui.QMainWindow, CommandBase):
|
|||
self.cancel_button.setEnabled(False)
|
||||
|
||||
def show_error(self, exception):
|
||||
QtGui.QMessageBox.information(self, 'Error!', unicode(exception))
|
||||
QtGui.QMessageBox.information(self, 'Error!', exception)
|
||||
|
||||
def disable_ui_while_working(self):
|
||||
self.option_settings_enabled(False)
|
||||
|
|
@ -413,10 +413,10 @@ class MainWindow(QtGui.QMainWindow, CommandBase):
|
|||
for sgroup in self.settings['setting_groups']+[self.settings['web2exe_settings']]:
|
||||
for sname, setting in sgroup.items():
|
||||
if setting.type in set(['file', 'folder']) and os.path.isabs(setting.value):
|
||||
setting_path = unicode(setting.value)
|
||||
setting_path = setting.value
|
||||
else:
|
||||
setting_path = utils.path_join(self.project_dir(),
|
||||
unicode(setting.value))
|
||||
setting.value)
|
||||
|
||||
if setting.required and not setting.value:
|
||||
settings_valid = False
|
||||
|
|
@ -605,7 +605,7 @@ class MainWindow(QtGui.QMainWindow, CommandBase):
|
|||
|
||||
@progress_text.setter
|
||||
def progress_text(self, value):
|
||||
self.progress_label.setText(unicode(value))
|
||||
self.progress_label.setText(value)
|
||||
|
||||
def run_in_background(self, method_name, callback):
|
||||
self.thread = BackgroundThread(self, method_name)
|
||||
|
|
@ -737,7 +737,7 @@ class MainWindow(QtGui.QMainWindow, CommandBase):
|
|||
|
||||
path = QUrl.toPercentEncoding(url.path(), "!$&'()*+,;=:@/")
|
||||
if path:
|
||||
path = unicode(path)
|
||||
path = str(path)
|
||||
else:
|
||||
path = u'/'
|
||||
|
||||
|
|
@ -1115,7 +1115,7 @@ class MainWindow(QtGui.QMainWindow, CommandBase):
|
|||
text.textChanged.connect(self.call_with_object('setting_changed',
|
||||
text, setting))
|
||||
if setting.value:
|
||||
text.setText(unicode(setting.value))
|
||||
text.setText(setting.value)
|
||||
text.setStatusTip(setting.description)
|
||||
text.setToolTip(setting.description)
|
||||
|
||||
|
|
@ -1139,7 +1139,7 @@ class MainWindow(QtGui.QMainWindow, CommandBase):
|
|||
text, setting))
|
||||
|
||||
if setting.value:
|
||||
text.setText(unicode(setting.value))
|
||||
text.setText(setting.value)
|
||||
text.setStatusTip(setting.description)
|
||||
text.setToolTip(setting.description)
|
||||
|
||||
|
|
@ -1167,7 +1167,7 @@ class MainWindow(QtGui.QMainWindow, CommandBase):
|
|||
text, setting))
|
||||
|
||||
if setting.value:
|
||||
text.setText(unicode(setting.value))
|
||||
text.setText(setting.value)
|
||||
text.setStatusTip(setting.description)
|
||||
text.setToolTip(setting.description)
|
||||
|
||||
|
|
@ -1195,12 +1195,12 @@ class MainWindow(QtGui.QMainWindow, CommandBase):
|
|||
old_val = setting.default_value
|
||||
|
||||
setting.value = old_val.replace('\\', '\\\\')
|
||||
widget.setText(unicode(old_val))
|
||||
widget.setText(old_val)
|
||||
elif setting.type == 'strings':
|
||||
old_val = []
|
||||
if setting.default_value is not None:
|
||||
old_val = setting.default_value
|
||||
setting.value = [unicode(v.replace('\\', '\\\\')) for v in old_val]
|
||||
setting.value = [v.replace('\\', '\\\\') for v in old_val]
|
||||
widget.setText(','.join(setting.value))
|
||||
|
||||
elif setting.type == 'check':
|
||||
|
|
@ -1222,10 +1222,10 @@ class MainWindow(QtGui.QMainWindow, CommandBase):
|
|||
def set_kiosk_emulation_options(self, is_checked):
|
||||
if is_checked:
|
||||
width_field = self.find_child_by_name('width')
|
||||
width_field.setText(unicode(self.desktop_width))
|
||||
width_field.setText(self.desktop_width)
|
||||
|
||||
height_field = self.find_child_by_name('height')
|
||||
height_field.setText(unicode(self.desktop_height))
|
||||
height_field.setText(self.desktop_height)
|
||||
|
||||
toolbar_field = self.find_child_by_name('toolbar')
|
||||
toolbar_field.setChecked(not is_checked)
|
||||
|
|
@ -1367,7 +1367,7 @@ class MainWindow(QtGui.QMainWindow, CommandBase):
|
|||
slider.setStatusTip(setting.description)
|
||||
slider.setToolTip(setting.description)
|
||||
|
||||
range_label = QtGui.QLabel(unicode(setting.default_value))
|
||||
range_label = QtGui.QLabel(str(setting.default_value))
|
||||
range_label.setMaximumWidth(30)
|
||||
|
||||
slider.valueChanged.connect(self.call_with_object('_update_range_label',
|
||||
|
|
@ -1384,7 +1384,7 @@ class MainWindow(QtGui.QMainWindow, CommandBase):
|
|||
return hlayout
|
||||
|
||||
def _update_range_label(self, label, value):
|
||||
label.setText(unicode(value))
|
||||
label.setText(str(value))
|
||||
|
||||
def load_package_json(self, json_path=None):
|
||||
setting_list = super(MainWindow, self).load_package_json(json_path)
|
||||
|
|
|
|||
2
pepy
2
pepy
|
|
@ -1 +1 @@
|
|||
Subproject commit 35b3b0097ff12a6ff7a98f001167fa16b497acd3
|
||||
Subproject commit fb6e7587ac721cb9996782f0eaaad85389e17f6c
|
||||
6
png.py
6
png.py
|
|
@ -1887,7 +1887,7 @@ class Reader:
|
|||
while True:
|
||||
try:
|
||||
type, data = self.chunk(lenient=lenient)
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
raise ChunkError(e.args[0])
|
||||
if type == 'IEND':
|
||||
# http://www.w3.org/TR/PNG/#11IEND
|
||||
|
|
@ -2752,5 +2752,5 @@ def _main(argv):
|
|||
if __name__ == '__main__':
|
||||
try:
|
||||
_main(sys.argv)
|
||||
except Error, e:
|
||||
print >>sys.stderr, e
|
||||
except Error as e:
|
||||
print(e, file=sys.stderr)
|
||||
|
|
|
|||
2
pycns.py
2
pycns.py
|
|
@ -27,7 +27,7 @@ def pngs_from_icns(icns_path):
|
|||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 3:
|
||||
print 'Usage: pycns input_image_path output_icns_path'
|
||||
print('Usage: pycns input_image_path output_icns_path')
|
||||
sys.exit()
|
||||
|
||||
image_path, icns_path = sys.argv[1:3]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
pillow
|
||||
qt
|
||||
pyside
|
||||
configobj
|
||||
semantic_version
|
||||
appdirs
|
||||
validators
|
||||
requests
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@ def main():
|
|||
rel_id = None
|
||||
upload_url = None
|
||||
|
||||
github_user = raw_input('Github user:')
|
||||
github_user = input('Github user:')
|
||||
|
||||
password = getpass.getpass('Password:')
|
||||
|
||||
if req.status_code == 200:
|
||||
print 'Found release:', version
|
||||
print('Found release:', version)
|
||||
json_data = json.loads(req.text)
|
||||
tag = json_data.get('tag_name', '')
|
||||
cur_ver = Version(tag[1:-1])
|
||||
|
|
@ -39,7 +39,7 @@ def main():
|
|||
upload_url = json_data['upload_url'].replace('{?name,label}', '')
|
||||
|
||||
if not update:
|
||||
print 'Creating release:', version
|
||||
print('Creating release:', version)
|
||||
data = {'tag_name': version,
|
||||
'target_commitish': 'master',
|
||||
'name': 'Web2Executable ' + version}
|
||||
|
|
@ -49,21 +49,21 @@ def main():
|
|||
upload_url = json_data['upload_url'].replace('{?name,label}', '')
|
||||
rel_id = json_data['id']
|
||||
else:
|
||||
print 'Authentication failed!'
|
||||
print('Authentication failed!')
|
||||
|
||||
if rel_id:
|
||||
zip_files = glob('*.zip')
|
||||
for zip_file in zip_files:
|
||||
with open(zip_file, 'rb') as zipf:
|
||||
file_data = zipf.read()
|
||||
print 'Uploading file {}...'.format(zip_file)
|
||||
print('Uploading file {}...'.format(zip_file))
|
||||
data = {'name': zip_file}
|
||||
headers = {'Content-Type': 'application/zip'}
|
||||
r = requests.post(upload_url, params=data, data=file_data, headers=headers, auth=(github_user, password))
|
||||
if r.status_code == 201:
|
||||
print 'Success!'
|
||||
print('Success!')
|
||||
else:
|
||||
print 'Error:', r.text
|
||||
print('Error:', r.text)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
29
utils.py
29
utils.py
|
|
@ -20,16 +20,9 @@ def get_temp_dir():
|
|||
return tempfile.gettempdir()
|
||||
|
||||
def path_join(base, *rest):
|
||||
try:
|
||||
base = base.decode('utf-8')
|
||||
except UnicodeEncodeError:
|
||||
base = unicode(base)
|
||||
new_rest = []
|
||||
for i in xrange(len(rest)):
|
||||
try:
|
||||
new_rest.append(rest[i].decode('utf-8'))
|
||||
except UnicodeEncodeError:
|
||||
new_rest.append(unicode(rest[i]))
|
||||
for i in range(len(rest)):
|
||||
new_rest.append(str(rest[i]))
|
||||
|
||||
rpath = u'/'.join(new_rest)
|
||||
|
||||
|
|
@ -37,7 +30,7 @@ def path_join(base, *rest):
|
|||
rpath = base + u'/' + rpath
|
||||
|
||||
if is_windows():
|
||||
rpath = rpath.replace(u'/', u'\\')
|
||||
rpath = rpath.replace('/', '\\')
|
||||
return rpath
|
||||
|
||||
def get_data_path(dir_path):
|
||||
|
|
@ -61,31 +54,31 @@ def get_data_file_path(file_path):
|
|||
def rmtree(path, **kwargs):
|
||||
if is_windows():
|
||||
if os.path.isabs(path):
|
||||
path = u'\\\\?\\'+path.replace(u'/', u'\\')
|
||||
path = '\\\\?\\'+path.replace('/', '\\')
|
||||
shutil.rmtree(path, **kwargs)
|
||||
|
||||
def copy(src, dest, **kwargs):
|
||||
if is_windows():
|
||||
if os.path.isabs(src):
|
||||
src = u'\\\\?\\'+src.replace(u'/', u'\\')
|
||||
src = '\\\\?\\'+src.replace('/', '\\')
|
||||
if os.path.isabs(dest):
|
||||
dest = u'\\\\?\\'+dest.replace(u'/', u'\\')
|
||||
dest = '\\\\?\\'+dest.replace('/', '\\')
|
||||
shutil.copy(src, dest, **kwargs)
|
||||
|
||||
def move(src, dest, **kwargs):
|
||||
if is_windows():
|
||||
if os.path.isabs(src):
|
||||
src = u'\\\\?\\'+src.replace(u'/', u'\\')
|
||||
src = '\\\\?\\'+src.replace('/', '\\')
|
||||
if os.path.isabs(dest):
|
||||
dest = u'\\\\?\\'+dest.replace(u'/', u'\\')
|
||||
dest = '\\\\?\\'+dest.replace('/', '\\')
|
||||
shutil.move(src, dest, **kwargs)
|
||||
|
||||
def copytree(src, dest, **kwargs):
|
||||
if is_windows():
|
||||
if os.path.isabs(src):
|
||||
src = u'\\\\?\\'+src.replace(u'/', u'\\')
|
||||
src = '\\\\?\\'+src.replace('/', '\\')
|
||||
if os.path.isabs(dest):
|
||||
dest = u'\\\\?\\'+dest.replace(u'/', u'\\')
|
||||
dest = '\\\\?\\'+dest.replace('/', '\\')
|
||||
shutil.copytree(src, dest, **kwargs)
|
||||
|
||||
def log(*args):
|
||||
|
|
@ -111,7 +104,7 @@ def zip_files(zip_file_name, *args, **kwargs):
|
|||
|
||||
for arg in args:
|
||||
if is_windows():
|
||||
arg = u'\\\\?\\'+os.path.abspath(arg).replace(u'/', u'\\')
|
||||
arg = '\\\\?\\'+os.path.abspath(arg).replace('/', '\\')
|
||||
if os.path.exists(arg):
|
||||
if os.path.isdir(arg):
|
||||
directory = os.path.abspath(arg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue