Changelog: bv.write and bv.insert require a bytes object in python3 Architecture.assemble outputs a bytes object in python3, a str in python2 Architecture.assemble will throw a value error if it cannot assemble the given instruction API install script should be run in the version of python you want it installed in Fundamental python changes to be aware of: Unicode-type strings are now just str, consequently anything that came out as a unicode string before (annotations) are now just str. Longs no longer exist. They're just ints.
Diffstat (limited to 'python/examples/version_switcher.py')
-rw-r--r--python/examples/version_switcher.py66
1 files changed, 33 insertions, 33 deletions
diff --git a/python/examples/version_switcher.py b/python/examples/version_switcher.py
index 3e1cab40..c990a6c0 100644
--- a/python/examples/version_switcher.py
+++ b/python/examples/version_switcher.py
@@ -34,15 +34,15 @@ def load_channel(newchannel):
global channel
global versions
if (channel is not None and newchannel == channel.name):
- print "Same channel, not updating."
+ print("Same channel, not updating.")
else:
try:
- print "Loading channel %s" % newchannel
+ print("Loading channel %s" % newchannel)
channel = UpdateChannel[newchannel]
- print "Loading versions..."
+ print("Loading versions...")
versions = channel.versions
except Exception:
- print "%s is not a valid channel name. Defaulting to " % chandefault
+ print("%s is not a valid channel name. Defaulting to " % chandefault)
channel = UpdateChannel[chandefault]
@@ -50,12 +50,12 @@ def select(version):
done = False
date = datetime.datetime.fromtimestamp(version.time).strftime('%c')
while not done:
- print "Version:\t%s" % version.version
- print "Updated:\t%s" % date
- print "Notes:\n\n-----\n%s" % version.notes
- print "-----"
- print "\t1)\tSwitch to version"
- print "\t2)\tMain Menu"
+ print("Version:\t%s" % version.version)
+ print("Updated:\t%s" % date)
+ print("Notes:\n\n-----\n%s" % version.notes)
+ print("-----")
+ print("\t1)\tSwitch to version")
+ print("\t2)\tMain Menu")
selection = raw_input('Choice: ')
if selection.isdigit():
selection = int(selection)
@@ -65,44 +65,44 @@ def select(version):
done = True
elif (selection == 1):
if (version.version == channel.latest_version.version):
- print "Requesting update to latest version."
+ print("Requesting update to latest version.")
else:
- print "Requesting update to prior version."
+ print("Requesting update to prior version.")
if are_auto_updates_enabled():
- print "Disabling automatic updates."
+ print("Disabling automatic updates.")
set_auto_updates_enabled(False)
if (version.version == core_version):
- print "Already running %s" % version.version
+ print("Already running %s" % version.version)
else:
- print "version.version %s" % version.version
- print "core_version %s" % core_version
- print "Downloading..."
- print version.update()
- print "Installing..."
+ print("version.version %s" % version.version)
+ print("core_version %s" % core_version)
+ print("Downloading...")
+ print(version.update())
+ print("Installing...")
if is_update_installation_pending:
#note that the GUI will be launched after update but should still do the upgrade headless
install_pending_update()
# forward updating won't work without reloading
sys.exit()
else:
- print "Invalid selection"
+ print("Invalid selection")
def list_channels():
done = False
- print "\tSelect channel:\n"
+ print("\tSelect channel:\n")
while not done:
channel_list = UpdateChannel.list
for index, item in enumerate(channel_list):
- print "\t%d)\t%s" % (index + 1, item.name)
- print "\t%d)\t%s" % (len(channel_list) + 1, "Main Menu")
+ print("\t%d)\t%s" % (index + 1, item.name))
+ print("\t%d)\t%s" % (len(channel_list) + 1, "Main Menu"))
selection = raw_input('Choice: ')
if selection.isdigit():
selection = int(selection)
else:
selection = 0
if (selection <= 0 or selection > len(channel_list) + 1):
- print "%s is an invalid choice." % selection
+ print("%s is an invalid choice." % selection)
else:
done = True
if (selection != len(channel_list) + 1):
@@ -118,23 +118,23 @@ def main():
done = False
load_channel(chandefault)
while not done:
- print "\n\tBinary Ninja Version Switcher"
- print "\t\tCurrent Channel:\t%s" % channel.name
- print "\t\tCurrent Version:\t%s" % core_version
- print "\t\tAuto-Updates On:\t%s\n" % are_auto_updates_enabled()
+ print("\n\tBinary Ninja Version Switcher")
+ print("\t\tCurrent Channel:\t%s" % channel.name)
+ print("\t\tCurrent Version:\t%s" % core_version)
+ print("\t\tAuto-Updates On:\t%s\n" % are_auto_updates_enabled())
for index, version in enumerate(versions):
date = datetime.datetime.fromtimestamp(version.time).strftime('%c')
- print "\t%d)\t%s (%s)" % (index + 1, version.version, date)
- print "\t%d)\t%s" % (len(versions) + 1, "Switch Channel")
- print "\t%d)\t%s" % (len(versions) + 2, "Toggle Auto Updates")
- print "\t%d)\t%s" % (len(versions) + 3, "Exit")
+ print("\t%d)\t%s (%s)" % (index + 1, version.version, date))
+ print("\t%d)\t%s" % (len(versions) + 1, "Switch Channel"))
+ print("\t%d)\t%s" % (len(versions) + 2, "Toggle Auto Updates"))
+ print("\t%d)\t%s" % (len(versions) + 3, "Exit"))
selection = raw_input('Choice: ')
if selection.isdigit():
selection = int(selection)
else:
selection = 0
if (selection <= 0 or selection > len(versions) + 3):
- print "%d is an invalid choice.\n\n" % selection
+ print("%d is an invalid choice.\n\n" % selection)
else:
if (selection == len(versions) + 3):
done = True