[entropy] more Python 2.6/3.x compat fixes
This commit is contained in:
+14
-12
@@ -737,45 +737,46 @@ def main():
|
||||
|
||||
except OnlineMirrorError as e:
|
||||
|
||||
print_error(darkred(" * ")+red(unicode(e)+". %s." % (_("Cannot continue"),) ))
|
||||
print_error("%s %s. %s." % (darkred(" * "), e, _("Cannot continue"),))
|
||||
raise SystemExit(101)
|
||||
|
||||
except RepositoryError as e:
|
||||
|
||||
reset_cache()
|
||||
print_error(darkred(" * ")+red(unicode(e)+". %s." % (_("Cannot continue"),) ))
|
||||
print_error("%s %s. %s." % (darkred(" * "), e, _("Cannot continue"),))
|
||||
raise SystemExit(101)
|
||||
|
||||
except FtpError as e:
|
||||
|
||||
print_error(darkred(" * ")+red(unicode(e)+". %s." % (_("Cannot continue"),) ))
|
||||
print_error("%s %s. %s." % (darkred(" * "), e, _("Cannot continue"),))
|
||||
raise SystemExit(101)
|
||||
|
||||
except PermissionDenied as e:
|
||||
|
||||
print_error(darkred(" * ")+red(unicode(e)+". %s." % (_("Cannot continue"),) ))
|
||||
print_error("%s %s. %s." % (darkred(" * "), e, _("Cannot continue"),))
|
||||
raise SystemExit(1)
|
||||
|
||||
except FileNotFound as e:
|
||||
|
||||
print_error(darkred(" * ")+red(unicode(e)+". %s." % (_("Cannot continue"),) ))
|
||||
print_error("%s %s. %s." % (darkred(" * "), e, _("Cannot continue"),))
|
||||
raise SystemExit(1)
|
||||
|
||||
except SPMError as e:
|
||||
|
||||
print_error(darkred(" * ")+red(unicode(e)+". %s." % (_("Cannot continue"),) ))
|
||||
print_error("%s %s. %s." % (darkred(" * "), e, _("Cannot continue"),))
|
||||
raise SystemExit(1)
|
||||
|
||||
except dbapi2Exceptions['OperationalError'] as e:
|
||||
|
||||
if unicode(e).find("disk I/O error") == -1:
|
||||
if str(e).find("disk I/O error") == -1:
|
||||
raise
|
||||
print_error(darkred(" * ")+red(unicode(e)+". %s." % (_("Cannot continue. Your hard disk is probably faulty."),) ))
|
||||
print_error("%s %s. %s." % (darkred(" * "), e,
|
||||
_("Cannot continue. Your hard disk is probably faulty."),))
|
||||
raise SystemExit(101)
|
||||
|
||||
except SystemError as e: # becoming from entropy.db
|
||||
|
||||
print_error(darkred(" * ")+red(unicode(e)+". %s." % (_("Cannot continue"),) ))
|
||||
print_error("%s %s. %s." % (darkred(" * "), e, _("Cannot continue"),))
|
||||
raise SystemExit(1)
|
||||
|
||||
except SystemExit:
|
||||
@@ -791,7 +792,8 @@ def main():
|
||||
|
||||
if e.errno == 28:
|
||||
entropyTools.print_exception()
|
||||
print_error(darkred(_("Your hard drive is full! Next time remember to have a look at it before starting. I'm sorry, there's nothing I can do for you. It's your fault :-(")))
|
||||
print_error("%s %s. %s." % (darkred(" * "), e,
|
||||
_("Your hard drive is full! Next time remember to have a look at it before starting. I'm sorry, there's nothing I can do for you. It's your fault :-("),))
|
||||
raise SystemExit(5)
|
||||
else:
|
||||
raise
|
||||
@@ -828,7 +830,7 @@ def main():
|
||||
ferror = open("/tmp/equoerror.txt","aw")
|
||||
ferror.write("\n\n")
|
||||
for x in exception_data:
|
||||
ferror.write(unicode(x)+"\n")
|
||||
ferror.write("%s\n" % (e,))
|
||||
ferror.flush()
|
||||
ferror.close()
|
||||
except Exception as e:
|
||||
@@ -859,7 +861,7 @@ def main():
|
||||
"/sabayonlinux.org/handlers/http_error_report.php"
|
||||
error = ErrorReportInterface(post_url)
|
||||
|
||||
error.prepare(errorText, name, email, '\n'.join([unicode(x) for x in exception_data]), description)
|
||||
error.prepare(errorText, name, email, '\n'.join([x for x in exception_data]), description)
|
||||
result = error.submit()
|
||||
if result:
|
||||
print_error(darkgreen(_("Thank you very much. The error has been reported and hopefully, the problem will be solved as soon as possible.")))
|
||||
|
||||
@@ -251,7 +251,7 @@ def search_changelog(atoms, dbconn = None, Equo = None):
|
||||
print_generic(_("No ChangeLog available"))
|
||||
else:
|
||||
print_generic(changelog)
|
||||
print("="*80)
|
||||
print_generic("="*80)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
@@ -1500,7 +1500,7 @@ class EntropyRepository:
|
||||
)
|
||||
|
||||
myidpackage_string = 'NULL'
|
||||
if isinstance(idpackage, (int, long)):
|
||||
if isinstance(idpackage, (int,)):
|
||||
|
||||
manual_deps = self.retrieveManualDependencies(idpackage)
|
||||
|
||||
@@ -4513,7 +4513,7 @@ class EntropyRepository:
|
||||
excluded_deptypes_query = ""
|
||||
if exclude_deptypes != None:
|
||||
for dep_type in exclude_deptypes:
|
||||
if not isinstance(dep_type, (int, long)):
|
||||
if not isinstance(dep_type, (int,)):
|
||||
# filter out crap
|
||||
continue
|
||||
excluded_deptypes_query += " AND dependencies.type != %s" % (
|
||||
@@ -8376,7 +8376,7 @@ class EntropyRepository:
|
||||
atomUse = ()
|
||||
atomSlot = self.entropyTools.dep_getslot(atom)
|
||||
atomRev = self.entropyTools.dep_get_entropy_revision(atom)
|
||||
if isinstance(atomRev, (int, long)):
|
||||
if isinstance(atomRev, (int,)):
|
||||
if atomRev < 0: atomRev = None
|
||||
|
||||
# use match
|
||||
|
||||
@@ -608,7 +608,7 @@ def movefile(src, dest, src_basedir = None):
|
||||
# The utime can fail here with EPERM even though the move succeeded.
|
||||
# Instead of failing, use stat to return the mtime if possible.
|
||||
try:
|
||||
long(os.stat(dest).st_mtime)
|
||||
int(os.stat(dest).st_mtime)
|
||||
return True
|
||||
except OSError as e:
|
||||
print_generic("!!! Failed to stat in movefile()\n")
|
||||
@@ -2622,7 +2622,11 @@ def isnumber(x):
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
return isinstance(x, (long, int))
|
||||
try:
|
||||
int(x)
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
def istextfile(filename, blocksize = 512):
|
||||
@@ -3515,7 +3519,7 @@ def is_valid_string(string):
|
||||
@return:
|
||||
@rtype:
|
||||
"""
|
||||
invalid = [ord(x) for x in string if ord(x) not in range(32, 127)]
|
||||
invalid = [ord(x) for x in string if ord(x) not in list(range(32, 127))]
|
||||
if invalid: return False
|
||||
return True
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ class _Total:
|
||||
return
|
||||
self.gtk_loop()
|
||||
self.lastFrac = now+0.01
|
||||
percent = long(self._percent(1, now))
|
||||
percent = int(self._percent(1, now))
|
||||
self.progress.set_fraction(now)
|
||||
if prefix:
|
||||
text = "%s : %3i%%" % (prefix, percent)
|
||||
|
||||
Reference in New Issue
Block a user