diff --git a/pulsar/client/action_mapper.py b/pulsar/client/action_mapper.py index 122d4abd585185e709da76a5a4f3742640483fba..96a70d97b0aa24b258527ec15ad4afacfb73cd55 100644 --- a/pulsar/client/action_mapper.py +++ b/pulsar/client/action_mapper.py @@ -625,7 +625,7 @@ class PrefixPathMapper(BasePathMapper): return path.startswith(self.prefix_path) def to_pattern(self): - pattern_str = "(%s%s[^\s,\"\']+)" % (escape(self.prefix_path), escape(sep)) + pattern_str = r"(%s%s[^\s,\"\']+)" % (escape(self.prefix_path), escape(sep)) return compile(pattern_str) def to_dict(self): diff --git a/pulsar/client/test/check.py b/pulsar/client/test/check.py index 04afc072fb718384d58ca3ab1f8d79c23d2ae1f5..6973bf7176e758ab86164557586fc719a1d57cb1 100644 --- a/pulsar/client/test/check.py +++ b/pulsar/client/test/check.py @@ -271,11 +271,11 @@ class Waiter(object): def __init__(self, client, client_manager): self.client = client self.client_manager = client_manager - self.async = hasattr(client_manager, 'ensure_has_status_update_callback') + self.background = hasattr(client_manager, 'ensure_has_status_update_callback') self.__setup_callback() def __setup_callback(self): - if self.async: + if self.background: self.event = threading.Event() def on_update(message): @@ -287,7 +287,7 @@ class Waiter(object): def wait(self, seconds=15): final_status = None - if not self.async: + if not self.background: i = 0 # Wait for seconds * 2 half second intervals while i < (seconds * 2): diff --git a/pulsar/client/transport/standard.py b/pulsar/client/transport/standard.py index 25ce84c490a2f4caf210300763dcd62d2f9ebf02..dc67ad25ee8c605d30823039d23204ee81368e4b 100644 --- a/pulsar/client/transport/standard.py +++ b/pulsar/client/transport/standard.py @@ -43,7 +43,7 @@ class Urllib2Transport(object): request.add_header('Content-Length', str(size)) try: response = self._url_open(request, data) - except socket.timeout as exc: + except socket.timeout: raise PulsarClientTransportError(code=PulsarClientTransportError.TIMEOUT) except URLError as exc: raise PulsarClientTransportError(transport_message=exc.reason) diff --git a/pulsar/managers/queued.py b/pulsar/managers/queued.py index face51dbe69e8a48bcbd0fa3a6142902dc794a69..3751878070c8244e75a6a1452b7613eed1df55e4 100644 --- a/pulsar/managers/queued.py +++ b/pulsar/managers/queued.py @@ -89,7 +89,7 @@ class QueueManager(Manager): except Exception: log.exception("Running command but failed to delete - command may rerun on Pulsar boot.") # _run will not do anything if job has been cancelled. - self._run(job_id, command_line, async=False) + self._run(job_id, command_line, background=False) except Exception: log.warn("Uncaught exception running job with job_id %s" % job_id) traceback.print_exc() diff --git a/pulsar/managers/unqueued.py b/pulsar/managers/unqueued.py index 321a4ba003a29f55ad8cba49c829d9a4dd44f175..5aba36198101355344db2004da497dac38f2ee50 100644 --- a/pulsar/managers/unqueued.py +++ b/pulsar/managers/unqueued.py @@ -123,7 +123,7 @@ class Manager(DirectoryBaseManager): self._job_directory(job_id).remove_metadata(JOB_FILE_SUBMITTED) return pid - def _run(self, job_id, command_line, async=True): + def _run(self, job_id, command_line, background=True): with self._get_job_lock(job_id): if self._was_cancelled(job_id): return @@ -137,7 +137,7 @@ class Manager(DirectoryBaseManager): stderr=stderr) with self._get_job_lock(job_id): self._record_pid(job_id, proc.pid) - if async: + if background: thread.start_new_thread(self._monitor_execution, (job_id, proc, stdout, stderr)) else: self._monitor_execution(job_id, proc, stdout, stderr) diff --git a/pulsar/managers/util/cli/job/slurm_torque.py b/pulsar/managers/util/cli/job/slurm_torque.py index b3de6099fbf4ef0e0a6c9f353cae763274a8b23e..9e13bf9f08e947204d0b8c163f81910ef0f357ae 100644 --- a/pulsar/managers/util/cli/job/slurm_torque.py +++ b/pulsar/managers/util/cli/job/slurm_torque.py @@ -18,7 +18,7 @@ class SlurmTorque(Torque): for line in status.strip().splitlines(): if line.startswith("Job ID"): continue - line_parts = re.compile("\s+").split(line) + line_parts = re.compile(r"\s+").split(line) if len(line_parts) < 5: continue id = line_parts[0] diff --git a/test/script_run_test.py b/test/script_run_test.py index 5998e1536f9be6ff7db7a3adad451d285d62568c..14fd4fbd699b24df1edf3a40619a48ddf4e41c55 100644 --- a/test/script_run_test.py +++ b/test/script_run_test.py @@ -31,7 +31,7 @@ class ScriptRunTestCase(TempDirectoryTestCase): "--command", "echo `pwd` > output1; cp input1 output_test2", "--working_directory", self._working_directory, "--output", "output1", - "--output_pattern", "output_test\d", + "--output_pattern", r"output_test\d", "--result_json", self._result, ]) exit_code = run.main(run_args) diff --git a/tox.ini b/tox.ini index d4561361e6115111e05c54677dfeb38cb538d6be..325be4b49d3b9001c9ca2b568e73c6fccda95fab 100644 --- a/tox.ini +++ b/tox.ini @@ -28,12 +28,12 @@ deps = [testenv:py27-lint] -commands = flake8 pulsar test +commands = flake8 --ignore W504 pulsar test skip_install = True deps = flake8 [testenv:py35-lint] -commands = flake8 pulsar test +commands = flake8 --ignore W504 pulsar test skip_install = True deps = flake8