-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcopy_and_run.py
More file actions
31 lines (22 loc) · 909 Bytes
/
copy_and_run.py
File metadata and controls
31 lines (22 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os.path
import uuid
from datetime import datetime
import shutil
from constants import FOLDERS_TO_EXCLUDE_COPYING
def copy_and_run(src, dest, files_or_folders_to_exclude):
unique_id = str(uuid.uuid4()).split('-')[0]
time_stamp = datetime.now().strftime("%d-%b-%Y__%H:%M:%S")
folder_to_copy = os.path.join(dest, os.path.basename(src) + '_' + time_stamp + '_' + unique_id)
def _ignore_(path, names):
return set(files_or_folders_to_exclude)
shutil.copytree(src, folder_to_copy, ignore=_ignore_)
print(f'Copied repo to: {folder_to_copy}')
return folder_to_copy
def default_copy_and_run(dest):
repo_path = copy_and_run(
src=os.path.dirname(os.path.realpath(__file__)),
dest=dest,
files_or_folders_to_exclude=FOLDERS_TO_EXCLUDE_COPYING)
return os.path.join(repo_path, 'main.py')
if __name__ == '__main__':
default_copy_and_run()