Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/molequeue/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from client import Client, Job, JobState, JobException, \
from .client import Client, Job, JobState, JobException, \
FilePath, FileContents, Queue, JobInformationException
8 changes: 4 additions & 4 deletions python/molequeue/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import tempfile
import sys

from utils import underscore_to_camelcase
from utils import camelcase_to_underscore
from utils import JsonRpc
from .utils import underscore_to_camelcase
from .utils import camelcase_to_underscore
from .utils import JsonRpc
import threading

class JobState:
Expand Down Expand Up @@ -270,7 +270,7 @@ def _wait_for_response(self, packet_id, timeout):
while self._request_response_map[packet_id] == None:
# need to set a wait time otherwise the wait can't be interrupted
# See http://bugs.python.org/issue8844
wait_time = sys.maxint
wait_time = sys.maxsize
if timeout != None:
wait_time = timeout - (time.time() - start)
if wait_time <= 0:
Expand Down
12 changes: 4 additions & 8 deletions python/molequeue/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
import re
import itertools
import types
import molequeue

class JsonRpc:
Expand All @@ -22,7 +21,7 @@ def generate_request(packet_id, method, parameters):
def json_to_job(json):
job = molequeue.Job()
# convert response into Job object
for key, value in json['result'].iteritems():
for key, value in json['result'].items():
field = camelcase_to_underscore(key)
if key in JsonRpc.INTERNAL_FIELDS:
field = '_' + field
Expand All @@ -34,7 +33,7 @@ def json_to_job(json):
def json_to_queues(json):
queues = []

for name, programs in json['result'].iteritems():
for name, programs in json['result'].items():
queue = molequeue.Queue();
queue.name = name
queue.programs = programs
Expand All @@ -46,12 +45,9 @@ def json_to_queues(json):
def object_to_json_params(job):
params = {}

for key, value in job.__dict__.iteritems():
for key, value in job.__dict__.items():
field = underscore_to_camelcase(key)

if type(value) == types.InstanceType:
value = JsonRpc.object_to_json_params(value)
Comment on lines -52 to -53
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

types.InstanceType is removed in python3 but I am not confident this modification is OK

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just coming back to MoleQueue - it looks okay, but I'll take a look as I work in on the modernization effort


params[field] = value

return params
Expand All @@ -64,7 +60,7 @@ def camelcase():

c = camelcase()

return ''.join(c.next()(x) for x in value.split('_'))
return ''.join(next(c)(x) for x in value.split('_'))

def camelcase_to_underscore(value):
operation = itertools.cycle((lambda x : x.lower(), lambda x : '_' + x.lower()))
Expand Down