Skip to content
Merged
Changes from 1 commit
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
23 changes: 15 additions & 8 deletions src/main/emme/toolbox/utilities/file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,11 @@ 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
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)
# copy all files (except Emme project, and other file_masks)
self._copy_dir(src=local_dir, dst=remote_dir, file_masks=file_masks)

self.log_report()

# data_explorer = _m.Modeller().desktop.data_explorer()
Expand Down Expand Up @@ -316,23 +317,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"
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):
self._report.append(error.output)
else:
raise
os.remove(exclude_filename)
self._report.append(_time.strftime("%c"))

Expand Down