|
55 | 55 | wasAborted exitStatus resourceUsage""") |
56 | 56 |
|
57 | 57 |
|
| 58 | +# Python 3 compatability help |
| 59 | +if sys.version_info < (3, 0): |
| 60 | + bytes = str |
| 61 | + str = unicode |
| 62 | + |
| 63 | + |
58 | 64 | class JobTemplate(object): |
59 | 65 |
|
60 | 66 | """A job to be submitted to the DRM.""" |
@@ -368,7 +374,9 @@ def control(jobId, operation): |
368 | 374 | jobs submitted by other DRMAA session in other DRMAA implementations |
369 | 375 | or jobs submitted via native utilities. |
370 | 376 | """ |
371 | | - c(drmaa_control, jobId.encode(), string_to_control_action(operation)) |
| 377 | + if isinstance(jobId, str): |
| 378 | + jobId = jobId.encode() |
| 379 | + c(drmaa_control, jobId, string_to_control_action(operation)) |
372 | 380 |
|
373 | 381 | # takes string list, num value and boolean, no return value |
374 | 382 | @staticmethod |
@@ -451,8 +459,10 @@ def wait(jobId, timeout=-1): |
451 | 459 | stat = c_int() |
452 | 460 | jid_out = create_string_buffer(128) |
453 | 461 | rusage = pointer(POINTER(drmaa_attr_values_t)()) |
454 | | - c(drmaa_wait, jobId.encode(), jid_out, sizeof(jid_out), byref(stat), |
455 | | - timeout, rusage) |
| 462 | + if isinstance(jobId, str): |
| 463 | + jobId = jobId.encode() |
| 464 | + c(drmaa_wait, jobId, jid_out, sizeof(jid_out), byref(stat), timeout, |
| 465 | + rusage) |
456 | 466 | res_usage = adapt_rusage(rusage) |
457 | 467 | exited = c_int() |
458 | 468 | c(drmaa_wifexited, byref(exited), stat) |
@@ -497,7 +507,9 @@ def jobStatus(jobId): |
497 | 507 | jobs return a FAILED status. |
498 | 508 | """ |
499 | 509 | status = c_int() |
500 | | - c(drmaa_job_ps, jobId.encode(), byref(status)) |
| 510 | + if isinstance(jobId, str): |
| 511 | + jobId = jobId.encode() |
| 512 | + c(drmaa_job_ps, jobId, byref(status)) |
501 | 513 | return status_to_string(status.value) |
502 | 514 |
|
503 | 515 | def __enter__(self): |
|
0 commit comments