.gitignore                         |    1 +
 tb3/dist-packages/tb3/__init__.py  |    2 +-
 tb3/dist-packages/tb3/repostate.py |    6 +++---
 tb3/dist-packages/tb3/scheduler.py |    8 ++++----
 tb3/replay-branch                  |    2 +-
 tb3/tb3                            |   20 ++++++++++----------
 tb3/tb3-local-client               |   12 ++++++------
 tb3/tests/helpers.py               |    2 +-
 tb3/tests/tb3-cli.py               |    2 +-
 tb3/tests/tb3-local-client.py      |    2 +-
 tb3/tests/tb3/repostate.py         |    6 +++---
 tb3/tests/tb3/scheduler.py         |    6 +++---
 12 files changed, 35 insertions(+), 34 deletions(-)

New commits:
commit c88440b1e1c6113f957fd063f0361b6986163698
Author: Bjoern Michaelsen <bjoern.michael...@canonical.com>
Date:   Wed Jul 31 03:23:06 2013 +0200

    add python bytecode to gitignore

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..04a41a2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+**.pyc
commit d5c46e6da56bf3c68d3e7650beff522b8996ad25
Author: Bjoern Michaelsen <bjoern.michael...@canonical.com>
Date:   Wed Jul 31 03:21:48 2013 +0200

    python2 -> python3 transition

diff --git a/tb3/dist-packages/tb3/__init__.py 
b/tb3/dist-packages/tb3/__init__.py
index c7a73e3..56b7d5a 100644
--- a/tb3/dist-packages/tb3/__init__.py
+++ b/tb3/dist-packages/tb3/__init__.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # This file is part of the LibreOffice project.
 #
diff --git a/tb3/dist-packages/tb3/repostate.py 
b/tb3/dist-packages/tb3/repostate.py
index 6963da5..fc5a1fe 100644
--- a/tb3/dist-packages/tb3/repostate.py
+++ b/tb3/dist-packages/tb3/repostate.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 #
 # This file is part of the LibreOffice project.
 #
@@ -22,7 +22,7 @@ class StateEncoder(json.JSONEncoder):
 class StateDecoder(json.JSONDecoder):
     def decode(self, s):
         obj = super(StateDecoder, self).decode(s)
-        for (key, value) in obj.iteritems():
+        for (key, value) in obj.items():
             if isinstance(value, list):
                 if value[0] == '__datetime__':
                     obj[key] = datetime.datetime.utcfromtimestamp(value[1])
diff --git a/tb3/dist-packages/tb3/scheduler.py 
b/tb3/dist-packages/tb3/scheduler.py
index 8e9beb1..0f85b4b 100644
--- a/tb3/dist-packages/tb3/scheduler.py
+++ b/tb3/dist-packages/tb3/scheduler.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # This file is part of the LibreOffice project.
 #
@@ -18,8 +18,8 @@ class Proposal:
         (self.score, self.commit, self.scheduler, self.platform, self.repo, 
self.branch) = (score, commit, scheduler, platform, repo, branch)
     def __repr__(self):
         return 'Proposal(%f, %s, %s, %s, %s, %s)' % (self.score, self.commit, 
self.scheduler, self.platform, self.repo, self.branch)
-    def __cmp__(self, other):
-        return other.score - self.score
+    def __lt__(self, other):
+        return self.score < other.score
 
 class Scheduler:
     def __init__(self, platform, branch, repo):
@@ -110,5 +110,5 @@ class MergeScheduler(Scheduler):
             for proposal in new_proposals:
                 proposal.score *= scheduler[0]
                 proposals.append(proposal)
-        return sorted(proposals)
+        return sorted(proposals, key=lambda p: -p.score)
 # vim: set et sw=4 ts=4:
diff --git a/tb3/replay-branch b/tb3/replay-branch
index 79fdfcc..d307fe7 100755
--- a/tb3/replay-branch
+++ b/tb3/replay-branch
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 #
 # This file is part of the LibreOffice project.
 #
diff --git a/tb3/tb3 b/tb3/tb3
index 850906b..6ab865e 100755
--- a/tb3/tb3
+++ b/tb3/tb3
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 #
 # This file is part of the LibreOffice project.
 #
@@ -40,12 +40,12 @@ def set_commit_running(parms):
     get_updater(parms).set_scheduled(parms['set_commit_running'], 
parms['builder'], parms['estimated_duration'])
 
 def show_state(parms):
-    if parms.has_key('format') and parms['format'] == 'json':
+    if 'format' in parms and parms['format'] == 'json':
         raise NotImplementedError
     print(get_repostate(parms))
     
 def show_history(parms):
-    if parms.has_key('format') and parms['format'] == 'json':
+    if 'format' in parms and parms['format'] == 'json':
         raise NotImplementedError
     history = tb3.repostate.RepoHistory(parms['platform'], parms['repo'])
     for (commit, state) in history.get_recent_commit_states(parms['branch'], 
parms['history_count']):
@@ -65,17 +65,17 @@ def show_proposals(parms):
         print(json.dumps([p.__dict__ for p in proposals]))
 
 def execute(parms):
-    if parms.has_key('estimated_duration') and 
type(parms['estimated_duration']) is float:
+    if 'estimated_duration' in parms and type(parms['estimated_duration']) is 
float:
         parms['estimated_duration'] = 
datetime.timedelta(minutes=parms['estimated_duration'])
     if parms['sync']:
         sync(parms)
-    if parms.has_key('set_commit_finished') and parms['set_commit_finished']:
+    if 'set_commit_finished' in parms and parms['set_commit_finished']:
         set_commit_finished(parms)
-    if parms.has_key('set_commit_running') and parms['set_commit_running']:
+    if 'set_commit_running' in parms and parms['set_commit_running']:
         set_commit_running(parms)
     if parms['show_state']:
         show_state(parms)
-    if parms.has_key('show_history') and parms['show_history']:
+    if 'show_history' in parms and parms['show_history']:
         show_history(parms)
     if parms['show_proposals']:
         show_proposals(parms)
@@ -128,11 +128,11 @@ if __name__ == '__main__':
     if fullcommand or commandname == 'tb3-show-proposals' or commandname == 
'tb3-show-history':
         parser.add_argument('--format', help='set format for proposals and 
history (default: text)', choices=['text', 'json'], default='text')
     args = vars(parser.parse_args())
-    if not args.has_key('builder') and (args.has_key('set_commit_running') or 
args.has_key('set_commit_finished')):
+    if not 'builder' in args and ('set_commit_running' in args or 
'set_commit_finished' in args):
         parser.print_help()
         sys.exit(1)
-    if args.has_key('set_commit_finished') or 
args.has_key('set_commit_running') or args.has_key('show_state') or 
args.has_key('show_history') or args.has_key('show_proposals'):
-        if not (args.has_key('branch') and args.has_key('platform')):
+    if 'set_commit_finished' in args or 'set_commit_running' in args or 
'show_state' in args or 'show_history' in args or 'show_proposals' in args:
+        if not 'branch' in args and 'platform' in args:
             parser.print_help()
             sys.exit(1)
     if not fullcommand:
diff --git a/tb3/tb3-local-client b/tb3/tb3-local-client
index 4c91de3..6665201 100755
--- a/tb3/tb3-local-client
+++ b/tb3/tb3-local-client
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 #
 # This file is part of the LibreOffice project.
 #
@@ -52,7 +52,7 @@ class LocalClient:
             return None
     def report_start(self, proposal):
         estimated_buildtime = float(120)
-        if self.buildtimes.has_key( (proposal['repo'], proposal['branch'], 
proposal['platform']) ):
+        if (proposal['repo'], proposal['branch'], proposal['platform']) in 
self.buildtimes:
             scenario_buildtimes = self.buildtimes[ (proposal['repo'], 
proposal['branch'], proposal['platform']) ]
             estimated_buildtime = 
scenario_buildtimes[len(scenario_buildtimes)/2]
         self.tb3(repo=proposal['repo'], branch=proposal['branch'], 
platform=proposal['platform'], set_commit_running=proposal['commit'], 
estimated_duration=estimated_buildtime)
@@ -74,7 +74,7 @@ class LocalClient:
             _out=outfile,
             _ok_code=range(256)).exit_code
         duration_in_minutes = ((datetime.datetime.now() - 
starttime).total_seconds())/60
-        if self.buildtimes.has_key( (proposal['repo'], proposal['branch'], 
proposal['platform']) ):
+        if (proposal['repo'], proposal['branch'], proposal['platform']) in 
self.buildtimes:
             scenario_buildtimes = self.buildtimes[ (proposal['repo'], 
proposal['branch'], proposal['platform']) ]
             scenario_buildtimes.append(duration_in_minutes)
             scenario_buildtimes = sorted(scenario_buildtimes)
@@ -99,11 +99,11 @@ class LocalClient:
                     proposal = p
             if not proposal or float(proposal['score']) < 
self.args['min_score']:
                 time.sleep(self.args['poll_idle_time'])
-        print proposal
+        print(proposal)
         try:
             self.report_start(proposal)
         except Exception as e:
-            print "except %s" % e
+            print("except %s" % e)
         result = self.run_build(proposal)
         self.report_result(proposal, result)
     def execute(self):
diff --git a/tb3/tests/helpers.py b/tb3/tests/helpers.py
index 821882f..a82d5d9 100755
--- a/tb3/tests/helpers.py
+++ b/tb3/tests/helpers.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 #
 # This file is part of the LibreOffice project.
 #
diff --git a/tb3/tests/tb3-cli.py b/tb3/tests/tb3-cli.py
index 0dbc906..84142af 100755
--- a/tb3/tests/tb3-cli.py
+++ b/tb3/tests/tb3-cli.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 #
 # This file is part of the LibreOffice project.
 #
diff --git a/tb3/tests/tb3-local-client.py b/tb3/tests/tb3-local-client.py
index 64e1c0f..d1de4c0 100755
--- a/tb3/tests/tb3-local-client.py
+++ b/tb3/tests/tb3-local-client.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 #
 # This file is part of the LibreOffice project.
 #
diff --git a/tb3/tests/tb3/repostate.py b/tb3/tests/tb3/repostate.py
index 436c3f3..8656697 100755
--- a/tb3/tests/tb3/repostate.py
+++ b/tb3/tests/tb3/repostate.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 #
 # This file is part of the LibreOffice project.
 #
@@ -75,8 +75,8 @@ class TestRepoHistory(unittest.TestCase):
         commitstate = tb3.repostate.CommitState(started=now, finished=now)
         self.history.set_commit_state(self.head, commitstate)
         commitstate = self.history.get_commit_state(self.head)
-        self.assertEqual(commitstate.started, now)
-        self.assertEqual(commitstate.finished, now)
+        self.assertLess(abs((commitstate.started - now).total_seconds()), 0.01)
+        self.assertLess(abs((commitstate.finished -now).total_seconds()), 0.01)
 
 class TestRepoUpdater(unittest.TestCase):
     def __resolve_ref(self, refname):
diff --git a/tb3/tests/tb3/scheduler.py b/tb3/tests/tb3/scheduler.py
index bf0e328..91b77dd 100755
--- a/tb3/tests/tb3/scheduler.py
+++ b/tb3/tests/tb3/scheduler.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
 #
 # This file is part of the LibreOffice project.
 #
@@ -24,11 +24,11 @@ class TestScheduler(unittest.TestCase):
     def _show_log(self, commit):
         for line in self.git("log", "--pretty=oneline", commit):
             sys.stdout.write(line)
-        print
+        print()
     def _show_proposals(self, proposals):
         for proposal in proposals:
             sys.stdout.write("%f %s" %(proposal.score, self.git("log", "-1", 
"--pretty=oneline",  proposal.commit)))
-        print
+        print()
     def setUp(self):
         (self.testdir, self.git) = helpers.createTestRepo()
         self.state = tb3.repostate.RepoState('linux', 'master', self.testdir)
commit fe44190941d30e0d753776e988124584664fce16
Author: Bjoern Michaelsen <bjoern.michael...@canonical.com>
Date:   Wed Jul 31 01:58:15 2013 +0200

    we hardcode a maximum, thus use min()

diff --git a/tb3/dist-packages/tb3/repostate.py 
b/tb3/dist-packages/tb3/repostate.py
index aee3061..6963da5 100644
--- a/tb3/dist-packages/tb3/repostate.py
+++ b/tb3/dist-packages/tb3/repostate.py
@@ -178,7 +178,7 @@ class RepoStateUpdater:
             self.repostate.clear_last_bad()
     def set_scheduled(self, commit, builder, estimated_duration):
         # FIXME: dont hardcode limit
-        estimated_duration = max(estimated_duration, 
datetime.timedelta(hours=4))
+        estimated_duration = min(estimated_duration, 
datetime.timedelta(hours=4))
         commitstate = CommitState('RUNNING', datetime.datetime.now(), builder, 
estimated_duration)
         self.repohistory.set_commit_state(commit, commitstate)
     def set_finished(self, commit, builder, state, artifactreference):
commit ba54447feda3b6276d6df96b90b24266b5fb333f
Author: Bjoern Michaelsen <bjoern.michael...@canonical.com>
Date:   Wed Jul 31 01:56:21 2013 +0200

    fix naming estimated_buildtime->estimated_duration

diff --git a/tb3/tb3-local-client b/tb3/tb3-local-client
index f2e02c7..4c91de3 100755
--- a/tb3/tb3-local-client
+++ b/tb3/tb3-local-client
@@ -55,7 +55,7 @@ class LocalClient:
         if self.buildtimes.has_key( (proposal['repo'], proposal['branch'], 
proposal['platform']) ):
             scenario_buildtimes = self.buildtimes[ (proposal['repo'], 
proposal['branch'], proposal['platform']) ]
             estimated_buildtime = 
scenario_buildtimes[len(scenario_buildtimes)/2]
-        self.tb3(repo=proposal['repo'], branch=proposal['branch'], 
platform=proposal['platform'], set_commit_running=proposal['commit'], 
estimated_buildtime=estimated_buildtime)
+        self.tb3(repo=proposal['repo'], branch=proposal['branch'], 
platform=proposal['platform'], set_commit_running=proposal['commit'], 
estimated_duration=estimated_buildtime)
     def run_build(self, proposal):
         buildtime = int(time.time()*100)
         if self.logdir:
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to