From f008c66283a01e96c9b0efca358db355b6221eb0 Mon Sep 17 00:00:00 2001 From: Manuel Guenther <manuel.guenther@idiap.ch> Date: Thu, 29 Aug 2013 21:55:43 +0200 Subject: [PATCH] Tried to make the code python 3 compatible; removed (unnecessary) dependence on bob. --- gridtk/local.py | 2 +- gridtk/models.py | 13 +++++++------ gridtk/tests/__init__.py | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gridtk/local.py b/gridtk/local.py index 015d4ca..e762941 100644 --- a/gridtk/local.py +++ b/gridtk/local.py @@ -143,7 +143,7 @@ class JobManagerLocal(JobManager): """Finalizes the execution of the job by writing the stdout and stderr results into the according log files.""" def write(file, std, process): f = std if file is None else open(str(file), 'w') - f.write(process.read()) + f.write(process.read().decode('utf-8')) self.lock() # get the files to write to diff --git a/gridtk/models.py b/gridtk/models.py index aeda6d2..de6541f 100644 --- a/gridtk/models.py +++ b/gridtk/models.py @@ -1,7 +1,6 @@ import sqlalchemy -from sqlalchemy import Table, Column, Integer, String, Boolean, ForeignKey -from bob.db.sqlalchemy_migration import Enum, relationship -from sqlalchemy.orm import backref +from sqlalchemy import Table, Column, Integer, String, Boolean, ForeignKey, Enum +from sqlalchemy.orm import backref, relationship from sqlalchemy.ext.declarative import declarative_base import os @@ -9,8 +8,10 @@ import sys if sys.version_info[0] >= 3: from pickle import dumps, loads + python_3 = True else: from cPickle import dumps, loads + python_3 = False from .tools import logger @@ -172,13 +173,13 @@ class Job(Base): def get_command_line(self): - return loads(str(self.command_line)) + return loads(self.command_line) if python_3 else loads(str(self.command_line)) def get_array(self): - return loads(str(self.array_string)) + return loads(self.array_string) if python_3 else loads(str(self.array_string)) def get_arguments(self): - return loads(str(self.grid_arguments)) + return loads(self.grid_arguments) if python_3 else loads(str(self.grid_arguments)) def get_jobs_we_wait_for(self): return [j.waited_for_job for j in self.jobs_we_have_to_wait_for if j.waited_for_job is not None] diff --git a/gridtk/tests/__init__.py b/gridtk/tests/__init__.py index e3f3d1e..c8ea43a 100644 --- a/gridtk/tests/__init__.py +++ b/gridtk/tests/__init__.py @@ -173,7 +173,7 @@ class GridTKTest(unittest.TestCase): jman.main(['./bin/jman', '--database', self.database, 'list', '--print-array-jobs']) print() - # test that the list command still works + # test that the report command works jman.main(['./bin/jman', '--database', self.database, 'report']) # clean-up -- GitLab