summaryrefslogtreecommitdiff
path: root/python/examples
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2017-03-05 13:12:01 -0500
committerPeter LaFosse <peter@vector35.com>2017-03-05 13:12:01 -0500
commitcf5997848b8819725315bd2c8dd8a04c70da3b63 (patch)
tree24d9360e3ccfaee361aca4d345072c142c386a41 /python/examples
parenta0132eed82d28d4408a2475847e1804a157b3dc1 (diff)
parent27f1271083efb09efc6405f91be893ab38dad9a0 (diff)
Merginging with dev
Diffstat (limited to 'python/examples')
-rwxr-xr-xpython/examples/export_svg.py9
-rw-r--r--python/examples/version_switcher.py34
2 files changed, 28 insertions, 15 deletions
diff --git a/python/examples/export_svg.py b/python/examples/export_svg.py
index 89bc41a1..95e2d62d 100755
--- a/python/examples/export_svg.py
+++ b/python/examples/export_svg.py
@@ -80,6 +80,10 @@ def render_svg(function):
fill: none;
stroke-width: 1px;
}
+ .back_edge {
+ fill: none;
+ stroke-width: 2px;
+ }
.UnconditionalBranch, .IndirectBranch {
stroke: rgb(128, 198, 233);
color: rgb(128, 198, 233);
@@ -197,7 +201,10 @@ def render_svg(function):
points += str(x * widthconst) + "," + str(y * heightconst) + " "
x, y = edge.points[-1]
points += str(x * widthconst) + "," + str(y * heightconst + 0) + " "
- edges += ' <polyline class="edge {type}" points="{points}" marker-end="url(#arrow-{type})"/>\n'.format(type=BranchType(edge.type).name, points=points)
+ if edge.back_edge:
+ edges += ' <polyline class="back_edge {type}" points="{points}" marker-end="url(#arrow-{type})"/>\n'.format(type=BranchType(edge.type).name, points=points)
+ else:
+ edges += ' <polyline class="edge {type}" points="{points}" marker-end="url(#arrow-{type})"/>\n'.format(type=BranchType(edge.type).name, points=points)
output += ' ' + edges + '\n'
output += ' </g>\n'
output += '</svg></html>'
diff --git a/python/examples/version_switcher.py b/python/examples/version_switcher.py
index bc4f576c..9d5bbf05 100644
--- a/python/examples/version_switcher.py
+++ b/python/examples/version_switcher.py
@@ -20,10 +20,12 @@
# IN THE SOFTWARE.
import sys
-import binaryninja
+
+from binaryninja.update import UpdateChannel, are_auto_updates_enabled, set_auto_updates_enabled, is_update_installation_pending, install_pending_update
+from binaryninja import core_version
import datetime
-chandefault = binaryninja.UpdateChannel.list[0].name
+chandefault = UpdateChannel.list[0].name
channel = None
versions = []
@@ -31,17 +33,17 @@ versions = []
def load_channel(newchannel):
global channel
global versions
- if (channel is None and newchannel == channel.name):
+ if (channel is not None and newchannel == channel.name):
print "Same channel, not updating."
else:
try:
print "Loading channel %s" % newchannel
- channel = binaryninja.UpdateChannel[newchannel]
+ channel = UpdateChannel[newchannel]
print "Loading versions..."
versions = channel.versions
except Exception:
print "%s is not a valid channel name. Defaulting to " % chandefault
- channel = binaryninja.UpdateChannel[chandefault]
+ channel = UpdateChannel[chandefault]
def select(version):
@@ -66,16 +68,20 @@ def select(version):
print "Requesting update to latest version."
else:
print "Requesting update to prior version."
- if binaryninja.are_auto_updates_enabled():
+ if are_auto_updates_enabled():
print "Disabling automatic updates."
- binaryninja.set_auto_updates_enabled(False)
- if (version.version == binaryninja.core_version):
+ set_auto_updates_enabled(False)
+ if (version.version == core_version):
print "Already running %s" % version.version
else:
print "version.version %s" % version.version
- print "binaryninja.core_version %s" % binaryninja.core_version
- print "Updating..."
+ 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:
@@ -86,7 +92,7 @@ def list_channels():
done = False
print "\tSelect channel:\n"
while not done:
- channel_list = binaryninja.UpdateChannel.list
+ 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")
@@ -104,7 +110,7 @@ def list_channels():
def toggle_updates():
- binaryninja.set_auto_updates_enabled(not binaryninja.are_auto_updates_enabled())
+ set_auto_updates_enabled(not are_auto_updates_enabled())
def main():
@@ -114,8 +120,8 @@ def main():
while not done:
print "\n\tBinary Ninja Version Switcher"
print "\t\tCurrent Channel:\t%s" % channel.name
- print "\t\tCurrent Version:\t%s" % binaryninja.core_version
- print "\t\tAuto-Updates On:\t%s\n" % binaryninja.are_auto_updates_enabled()
+ 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)