Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions src/main/emme/toolbox/utilities/file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,12 @@ def upload(self, remote_dir, user_folder, scenario_id, delete_local_files, file_
file_masks.append(_join(local_dir, "emme_project"))

title_fcn = lambda t: t[8:] if t.startswith("(local)") else t
emmebank_paths = self._copy_emme_data(
src=local_dir, dst=remote_dir, title_fcn=title_fcn, scenario_id=scenario_id)
# copy all files (except Emme project, and other file_masks)
self._copy_dir(src=local_dir, dst=remote_dir, file_masks=file_masks)
emmebank_paths = self._copy_emme_data(
src=local_dir, dst=remote_dir, title_fcn=title_fcn, scenario_id=scenario_id)


self.log_report()

# data_explorer = _m.Modeller().desktop.data_explorer()
Expand Down Expand Up @@ -316,23 +318,29 @@ def _copy_emme_data(self, src, dst, title_fcn, scenario_id, initialize=False):
def _copy_dir(self, src, dst, file_masks, check_metadata=False):

# windows xcopy is much faster than shutil
# upgrading xcopy to a faster robocopy
self._report.append(_time.strftime("%c"))
exclude_filename = "TEMP_file_manager_exclude.txt"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exclude_file and exclude_filename can be removed, as these were only needed for xcopy. Only need exclude_file_list for robocopy

exclude_file = open(exclude_filename, "a+")
for x in file_masks + [exclude_filename]:
exclude_file.write(x + '\n')
exclude_file.close()
if check_metadata:
flags = '/Y/S/E/D'
else:
flags = '/Y/S/E'
# if check_metadata:
# flags = '/Y/S/E/D'
# else:
# flags = '/Y/S/E'
try:
output = _subprocess.check_output(['xcopy', flags, src, dst, "/exclude:" + exclude_filename])
exclude_file_list = file_masks + [exclude_filename]
flags = ['/E', '/Z', '/MT:8']
output = _subprocess.check_output(['robocopy', src, dst] + flags + ["/XF"] + exclude_file_list + ["/XD"] + exclude_file_list)
self._report.append(output)
except _subprocess.CalledProcessError as error:
self._report.append(error.output)
self.log_report()
raise
self._report.append(output)
if (error.returncode < 16) and (error.returncode > 0):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check return code >=8 to indicate an error, remove duplicate report append

self._report.append(error.output)
else:
raise
os.remove(exclude_filename)
self._report.append(_time.strftime("%c"))

Expand Down