|
10 | 10 | config = json.load(f)
|
11 | 11 | urls = config["access_modules"]["git_urls"]
|
12 | 12 |
|
13 |
| - for each_access_module in os.listdir('Access/access_modules'): |
14 |
| - path_to_remove = "Access/access_modules/%s" % each_access_module |
15 |
| - print("Deleting %s" % path_to_remove) |
16 |
| - try: |
17 |
| - if os.path.isdir(path_to_remove): |
18 |
| - shutil.rmtree(path_to_remove) |
19 |
| - except Exception as e: |
20 |
| - print("Got Error while deleting the path %s. Error: %s" % (path_to_remove, str(e))) |
| 13 | + if not os.path.exists('Access/access_modules'): |
| 14 | + os.mkdir('Access/access_modules') |
| 15 | + else: |
| 16 | + for each_access_module in os.listdir('Access/access_modules'): |
| 17 | + path_to_remove = "Access/access_modules/%s" % each_access_module |
| 18 | + print("Deleting %s" % path_to_remove) |
| 19 | + try: |
| 20 | + if os.path.isdir(path_to_remove): |
| 21 | + shutil.rmtree(path_to_remove) |
| 22 | + except Exception as e: |
| 23 | + print("Got Error while deleting the path %s. Error: %s" % (path_to_remove, str(e))) |
| 24 | + |
21 | 25 | shutil.copyfile('Access/base_email_access/access_modules_init.py', "Access/access_modules/__init__.py")
|
22 | 26 |
|
23 | 27 | requirements_file = 'Access/access_modules/requirements.txt'
|
|
52 | 56 | )
|
53 | 57 | except:
|
54 | 58 | print("File is already present.")
|
55 |
| - |
| 59 | + |
56 | 60 | if(file == "requirements.txt"):
|
57 | 61 | current_requirements_file = folder_path + "/" + file
|
58 | 62 | #Read the requirements
|
|
64 | 68 |
|
65 | 69 | # Merge the requirements
|
66 | 70 | merged_requirements = list(set(requirements1 + requirements2))
|
67 |
| - |
| 71 | + |
68 | 72 | #update the requirements.txt
|
69 | 73 | with open(requirements_file, 'w') as out_file:
|
70 | 74 | for requirement in sorted(merged_requirements):
|
71 | 75 | out_file.write(requirement)
|
72 |
| - |
| 76 | + |
73 | 77 | print("Cloning successful!")
|
74 | 78 | except Exception as e:
|
75 | 79 | print("error-->",e)
|
|
84 | 88 | except Exception as e:
|
85 | 89 | print(e)
|
86 | 90 | print("failed to remove " + folder_path + " folder.")
|
87 |
| - |
| 91 | + |
88 | 92 | except Exception as e:
|
89 | 93 | print("Access module cloning failed!")
|
90 | 94 | print(str(e))
|
|
0 commit comments