def _download_output_file(self): ssh = SSH_Client(self.server) remote_file_path = os.path.join(self.remote_path, output_filename[self.software]) local_file_path = os.path.join(self.local_path, 'output.out') ssh.download_file(remote_file_path=remote_file_path, local_file_path=local_file_path) if self.job_type == 'orbitals': remote_file_path = os.path.join(self.remote_path, 'input.FChk') local_file_path = os.path.join(self.local_path_to_orbitals_file) ssh.download_file(remote_file_path=remote_file_path, local_file_path=local_file_path) self.final_time = ssh.get_last_modified_time(remote_file_path=remote_file_path) self.determine_run_time() if not os.path.isfile(local_file_path): raise JobError('output file for {0} was not downloaded properly'.format(self.job_name))
def _get_additional_job_info(self): """ Download the additional information of stdout and stderr from the server """ lines1, lines2 = list(), list() content = '' ssh = SSH_Client(self.server) cluster_soft = servers[self.server]['cluster_soft'].lower() if cluster_soft in ['oge', 'sge']: remote_file_path = os.path.join(self.remote_path, 'out.txt') local_file_path1 = os.path.join(self.local_path, 'out.txt') try: ssh.download_file(remote_file_path=remote_file_path, local_file_path=local_file_path1) except (TypeError, IOError) as e: logging.warning('Got the following error when trying to download out.txt for {0}:'.format(self.job_name)) logging.warning(e.message) remote_file_path = os.path.join(self.remote_path, 'err.txt') local_file_path2 = os.path.join(self.local_path, 'err.txt') try: ssh.download_file(remote_file_path=remote_file_path, local_file_path=local_file_path2) except (TypeError, IOError) as e: logging.warning('Got the following error when trying to download err.txt for {0}:'.format(self.job_name)) logging.warning(e.message) if os.path.isfile(local_file_path1): with open(local_file_path1, 'r') as f: lines1 = f.readlines() if os.path.isfile(local_file_path2): with open(local_file_path2, 'r') as f: lines2 = f.readlines() content += ''.join([line for line in lines1]) content += '\n' content += ''.join([line for line in lines2]) elif cluster_soft == 'slurm': respond = ssh.send_command_to_server(command='ls -alF', remote_path=self.remote_path) files = list() for line in respond[0][0].splitlines(): files.append(line.split()[-1]) for file in files: if 'slurm' in file and '.out' in file: remote_file_path = os.path.join(self.remote_path, file) local_file_path = os.path.join(self.local_path, file) try: ssh.download_file(remote_file_path=remote_file_path, local_file_path=local_file_path) except (TypeError, IOError) as e: logging.warning('Got the following error when trying to download {0} for {1}:'.format( file, self.job_name)) logging.warning(e.message) if os.path.isfile(local_file_path): with open(local_file_path, 'r') as f: lines1 = f.readlines() content += ''.join([line for line in lines1]) content += '\n' return content