Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e801f55d authored by Luca Stefani's avatar Luca Stefani
Browse files

Add python3 support

Change-Id: Iccbd31eae3fc367f711b2e76d7010fd2e0e8e186
parent 0b388e76
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

import os
import os.path
import re
+13 −9
Original line number Diff line number Diff line
@@ -14,8 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import print_function

import sys
import os

try:
  from hashlib import sha1
@@ -52,8 +53,9 @@ for item in sys.argv[2:]:
  try:
    f = open(fn + ".sha1")
  except IOError:
    if not bad: print
    print "*** Error opening \"%s.sha1\"; can't verify %s" % (fn, key)
    if not bad:
      print()
    print("*** Error opening \"%s.sha1\"; can't verify %s" % (fn, key))
    bad = True
    continue
  for line in f:
@@ -63,17 +65,19 @@ for item in sys.argv[2:]:
    versions[h] = v

  if digest not in versions:
    if not bad: print
    print "*** SHA-1 hash of \"%s\" doesn't appear in \"%s.sha1\"" % (fn, fn)
    if not bad:
      print()
    print("*** SHA-1 hash of \"%s\" doesn't appear in \"%s.sha1\"" % (fn, fn))
    bad = True
    continue

  if versions[digest] not in values:
    if not bad: print
    print "*** \"%s\" is version %s; not any %s allowed by \"%s\"." % (
        fn, versions[digest], key, sys.argv[1])
    if not bad:
      print()
    print("*** \"%s\" is version %s; not any %s allowed by \"%s\"." % (
        fn, versions[digest], key, sys.argv[1]))
    bad = True

if bad:
  print
  print()
  sys.exit(1)
+3 −3
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@

from __future__ import print_function

import cgi, os, string, sys
import cgi, os, sys


def iteritems(obj):
@@ -42,10 +42,10 @@ def main(argv):
  data = {}
  index = 0
  for input in inputs:
    f = file(input, "r")
    f = open(input)
    lines = f.readlines()
    f.close()
    lines = map(string.split, lines)
    lines = [l.strip() for l in lines]
    lines = [(x_y[1],int(x_y[0])) for x_y in lines]
    for fn,sz in lines:
      if fn not in data:
+4 −2
Original line number Diff line number Diff line
@@ -34,11 +34,13 @@ Format of current_overlays.txt and previous_overlays.txt:
  ...
"""

from __future__ import print_function

import sys

def main(argv):
  if len(argv) != 4:
    print >> sys.stderr, __doc__
    print(sys.stderr, __doc__)
    sys.exit(1)

  f = open(argv[1])
@@ -85,7 +87,7 @@ def main(argv):

  # Print out the package names that have overlay change.
  for r in result:
    print r
    print(r)

if __name__ == "__main__":
  main(sys.argv)
+6 −4
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@

"""A module for reading and parsing event-log-tags files."""

from __future__ import print_function

import re
import sys

@@ -55,7 +57,7 @@ class TagFile(object):
    if file_object is None:
      try:
        file_object = open(filename, "rb")
      except (IOError, OSError), e:
      except (IOError, OSError) as e:
        self.AddError(str(e))
        return

@@ -100,7 +102,7 @@ class TagFile(object):

        self.tags.append(Tag(tag, tagname, description,
                             self.filename, self.linenum))
    except (IOError, OSError), e:
    except (IOError, OSError) as e:
      self.AddError(str(e))


@@ -130,6 +132,6 @@ def WriteOutput(output_file, data):
      out = open(output_file, "wb")
    out.write(data)
    out.close()
  except (IOError, OSError), e:
    print >> sys.stderr, "failed to write %s: %s" % (output_file, e)
  except (IOError, OSError) as e:
    print("failed to write %s: %s" % (output_file, e), file=sys.stderr)
    sys.exit(1)
Loading