Skip to content

Commit

Permalink
More clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
arjoly committed Jan 23, 2015
1 parent 0e0899e commit 292ecc3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 2 additions & 0 deletions clusterlib/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@


def _sge_queued_or_running_jobs(user=None):
"""Get queued or running jobs from SGE queue system"""
command = "qstat -xml"
if user is not None:
command += " -u {}".format(user)
Expand All @@ -40,6 +41,7 @@ def _sge_queued_or_running_jobs(user=None):


def _slurm_queued_or_running_jobs(user=None):
"""Get queued or running jobs from SLURM queue system"""
command = "squeue --noheader -o %j"
if user is not None:
command += " -u {}".format(user)
Expand Down
16 changes: 7 additions & 9 deletions clusterlib/tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@
from ..scheduler import submit


if sys.version_info[0] == 2:
bytes = str
str = unicode

elif sys.version_info[0] == 3:
str = str
bytes = bytes


def test_queued_or_running_jobs_slurm():
"""Test queued or running job function on slurm"""

Expand Down Expand Up @@ -60,6 +51,13 @@ def test_queued_or_running_jobs_slurm():
try:
running_jobs = queued_or_running_jobs(user=user)
if sys.version_info[0] == 3:
# the bytes should be decoded before, right after you read them
# (e.g. from a socket or a file). In Python 2 is done
# implicitly with a random (platform specific) encoding.
# In Python 3 youhave to decode bytes objects into unicode
# string explicitly with an appropriate encoding depending on
# where the bytes come from.

running_jobs = [s.decode("utf8") for s in running_jobs]

assert_in(job_name, running_jobs)
Expand Down

0 comments on commit 292ecc3

Please sign in to comment.