Skip to content

Commit

Permalink
Python 3 compatibility, fix aseba-community#888
Browse files Browse the repository at this point in the history
  • Loading branch information
Guilhem Saurel committed Nov 28, 2018
1 parent de30ede commit 31bd6d1
Show file tree
Hide file tree
Showing 28 changed files with 712 additions and 702 deletions.
124 changes: 61 additions & 63 deletions CMakeModules/sign.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
#!/usr/bin/python

from subprocess import call
import sys
import os
import shutil
import sys
from subprocess import call

timestamp_server = "http://timestamp.digicert.com"
url = "http://http://www.mobsya.org/"

binary = sys.argv[1] if len(sys.argv) > 1 else None
exists = binary != None and os.path.isfile(binary)
exists = binary is not None and os.path.isfile(binary)

scp = os.environ.get("SIGNTOOL_SCP")
key = os.environ.get("SIGNTOOL_KEY")
pfx = os.environ.get("SIGNTOOL_PFX")
pss = os.environ.get("SIGNTOOL_PASSPHRASE")
scp = os.environ.get("SIGNTOOL_SCP")
key = os.environ.get("SIGNTOOL_KEY")
pfx = os.environ.get("SIGNTOOL_PFX")
pss = os.environ.get("SIGNTOOL_PASSPHRASE")

if binary and not exists:
print("File {} does not exist".format(binary))
exit(1)
print("File {} does not exist".format(binary))
exit(1)

elif not exists or not ((scp and key) or (pss and pfx)):
print(
"""
print("""
Usage {} <binary>
Sign a binary with either osslsigncode or signcode(win32)
Expand All @@ -36,61 +35,60 @@
* SIGNTOOL_PFX : Must be the path of a valid pfx file
* SIGNTOOL_PASSPHRASE : Passphrase of the PFX file
"""
)
exit(1)
""")
exit(1)

_, ext = os.path.splitext(binary)
if ext[1:] not in ['exe', 'dll']:
print("Not a signable file, ignoring")
exit(0)

print("Not a signable file, ignoring")
exit(0)

#signtool ( native windows)
# signtool ( native windows)
if pss and pfx:
print("Signing with signtool")
if not os.path.isfile(pfx):
print("signtool: No PFX File Found ({} does not exist)".format(pfx))
exit(1)
ret = call([
"signtool", "sign"
"/f" , pfx,
"/p" , pss,
"/fd" , "sha256",
"/td" , "sha256",
"/du" , url,
"/tr" , timestamp_server,
"/as" , binary,
])
if ret != 0:
print("signtool failed (ret {})".format(ret))
exit(ret)

#signcode
print("Signing with signtool")
if not os.path.isfile(pfx):
print("signtool: No PFX File Found ({} does not exist)".format(pfx))
exit(1)
ret = call([
"signtool",
"sign"
"/f",
pfx,
"/p",
pss,
"/fd",
"sha256",
"/td",
"sha256",
"/du",
url,
"/tr",
timestamp_server,
"/as",
binary,
])
if ret != 0:
print("signtool failed (ret {})".format(ret))
exit(ret)

# signcode
if scp and key:
print("Signing with osslsigncode")
if not os.path.isfile(scp):
print("signcode: No SCP File Found ({} does not exist)".format(scp))
exit(1)
if not os.path.isfile(key):
print("signcode: No KEY File Found ({} does not exist)".format(key))
exit(1)

out = binary+".signed"

ret = call([
"osslsigncode",
"-spc", scp,
"-key", key,
"-h" , "sha256",
"-i" , url,
"-t" , timestamp_server,
"-in" , binary,
"-out", out
])
if(os.path.isfile(out)):
shutil.move(out, binary)
if ret != 0:
print("osslsigncode failed (ret {})".format(ret))
exit(ret)

print("Signing with osslsigncode")
if not os.path.isfile(scp):
print("signcode: No SCP File Found ({} does not exist)".format(scp))
exit(1)
if not os.path.isfile(key):
print("signcode: No KEY File Found ({} does not exist)".format(key))
exit(1)

out = binary + ".signed"

ret = call([
"osslsigncode", "-spc", scp, "-key", key, "-h", "sha256", "-i", url, "-t", timestamp_server, "-in", binary,
"-out", out
])
if (os.path.isfile(out)):
shutil.move(out, binary)
if ret != 0:
print("osslsigncode failed (ret {})".format(ret))
exit(ret)
39 changes: 14 additions & 25 deletions docs/en/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
# import sys
# sys.path.insert(0, os.path.abspath('.'))

import subprocess, os
import subprocess

subprocess.call('cd ../doxygen; doxygen', shell=True)

# -- General configuration ------------------------------------------------
Expand All @@ -32,10 +33,12 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.imgmath',
'sphinx.ext.githubpages', 'sphinx.ext.intersphinx', 'sphinx.ext.imgmath', 'sphinx.ext.todo', 'breathe']
extensions = [
'sphinx.ext.imgmath', 'sphinx.ext.githubpages', 'sphinx.ext.intersphinx', 'sphinx.ext.imgmath', 'sphinx.ext.todo',
'breathe'
]

breathe_projects = { "aseba": "../doxygen/doc/xml" }
breathe_projects = {"aseba": "../doxygen/doc/xml"}
breathe_default_project = "aseba"

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -82,19 +85,20 @@
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False


# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'


# Use a style similar to the Linux Kernel documentation. as
# it is more usable than the default RTD theme
def setup(app):
app.add_stylesheet('theme_overrides.css')


# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
Expand All @@ -111,18 +115,13 @@ def setup(app):
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
]
}

html_sidebars = {'**': []}

# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'Asebadoc'


# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
Expand All @@ -147,31 +146,21 @@ def setup(app):
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Aseba.tex', u'Aseba Documentation',
u'Stéphane Magnenat and other contributors', 'manual'),
(master_doc, 'Aseba.tex', u'Aseba Documentation', u'Stéphane Magnenat and other contributors', 'manual'),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'aseba', u'Aseba Documentation',
[author], 1)
]

man_pages = [(master_doc, 'aseba', u'Aseba Documentation', [author], 1)]

# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'Aseba', u'Aseba Documentation',
author, 'Aseba', 'A set of tools which allow beginners to program robots easily and efficiently.',
'Miscellaneous'),
(master_doc, 'Aseba', u'Aseba Documentation', author, 'Aseba',
'A set of tools which allow beginners to program robots easily and efficiently.', 'Miscellaneous'),
]



Loading

0 comments on commit 31bd6d1

Please sign in to comment.