diff --git a/src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py b/src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py index 6c82a987..6f76be4e 100644 --- a/src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py +++ b/src/zos_jobs/zowe/zos_jobs_for_zowe_sdk/jobs.py @@ -77,7 +77,7 @@ def cancel_job(self, jobname, jobid): request_url = "{}{}".format(self.request_endpoint, job_url) custom_args["url"] = request_url custom_args["json"] = {"request": "cancel"} - response_json = self.request_handler.perform_request("PUT", custom_args, expected_code = [202]) + response_json = self.request_handler.perform_request("PUT", custom_args, expected_code=[202]) return response_json def delete_job(self, jobname, jobid): @@ -99,7 +99,7 @@ def delete_job(self, jobname, jobid): job_url = "{}/{}".format(jobname, jobid) request_url = "{}{}".format(self.request_endpoint, job_url) custom_args["url"] = request_url - response_json = self.request_handler.perform_request("DELETE", custom_args, expected_code = [202]) + response_json = self.request_handler.perform_request("DELETE", custom_args, expected_code=[202]) return response_json def list_jobs(self, owner=None, prefix="*", max_jobs=1000, user_correlator=None): @@ -123,7 +123,7 @@ def list_jobs(self, owner=None, prefix="*", max_jobs=1000, user_correlator=None """ custom_args = self._create_custom_request_arguments() params = {"prefix": prefix, "max-jobs": max_jobs} - params["owner"] = owner if owner else self.connection.user + params["owner"] = owner if owner else self.session.user if user_correlator: params["user-correlator"] = user_correlator custom_args["params"] = params @@ -202,8 +202,7 @@ def submit_plaintext(self, jcl): ) return response_json - - def get_spool_files(self,correlator): + def get_spool_files(self, correlator): """Retrieve the spool files for a job identified by the correlator. Parameters @@ -223,7 +222,7 @@ def get_spool_files(self,correlator): response_json = self.request_handler.perform_request("GET", custom_args) return response_json - def get_jcl_text(self,correlator): + def get_jcl_text(self, correlator): """Retrieve the input JCL text for job with specified correlator Parameters ---------- @@ -242,7 +241,7 @@ def get_jcl_text(self,correlator): response_json = self.request_handler.perform_request("GET", custom_args) return response_json - def get_spool_file_contents(self,correlator,id): + def get_spool_file_contents(self, correlator, id): """Retrieve the contents of a single spool file from a job @@ -260,13 +259,13 @@ def get_spool_file_contents(self,correlator,id): A JSON containing the result of the request execution """ custom_args = self._create_custom_request_arguments() - job_url = "{}/files/{}/records".format(correlator,id) + job_url = "{}/files/{}/records".format(correlator, id) request_url = "{}{}".format(self.request_endpoint, job_url) custom_args["url"] = request_url response_json = self.request_handler.perform_request("GET", custom_args) return response_json - def get_job_output_as_files(self,status,output_dir): + def get_job_output_as_files(self, status, output_dir): """This method will get all the spool files as well as the submitted jcl text in separate files in the specified output directory. The structure will be as follows: @@ -302,12 +301,12 @@ def get_job_output_as_files(self,status,output_dir): _job_id = status['jobid'] _job_correlator = status['job-correlator'] - _output_dir = os.path.join(output_dir,_job_name,_job_id) - os.makedirs(_output_dir,exist_ok=True) - _output_file = os.path.join(output_dir,_job_name,_job_id,'jcl.txt') + _output_dir = os.path.join(output_dir, _job_name, _job_id) + os.makedirs(_output_dir, exist_ok=True) + _output_file = os.path.join(output_dir, _job_name, _job_id, 'jcl.txt') _data_spool_file = self.get_jcl_text(_job_correlator) _dataset_content = _data_spool_file['response'] - _out_file = open(_output_file,'w') + _out_file = open(_output_file, 'w') _out_file.write(_dataset_content) _out_file.close() @@ -316,13 +315,13 @@ def get_job_output_as_files(self,status,output_dir): _stepname = _spool_file['stepname'] _ddname = _spool_file['ddname'] _spoolfile_id = _spool_file['id'] - _output_dir = os.path.join(output_dir,_job_name,_job_id,_stepname) - os.makedirs(_output_dir,exist_ok=True) + _output_dir = os.path.join(output_dir, _job_name, _job_id, _stepname) + os.makedirs(_output_dir, exist_ok=True) - _output_file = os.path.join(output_dir,_job_name,_job_id,_stepname,_ddname) - _data_spool_file = self.get_spool_file_contents(_job_correlator,_spoolfile_id) + _output_file = os.path.join(output_dir, _job_name, _job_id, _stepname, _ddname) + _data_spool_file = self.get_spool_file_contents(_job_correlator, _spoolfile_id) _dataset_content = _data_spool_file['response'] - _out_file = open(_output_file,'w') + _out_file = open(_output_file, 'w') _out_file.write(_dataset_content) _out_file.close()