Skip to content
Snippets Groups Projects
Verified Commit a99eb8f6 authored by steven.liatti's avatar steven.liatti
Browse files

Refactor some code for compatibility with older than 3.9 python

parent 97de563c
No related branches found
No related tags found
No related merge requests found
...@@ -33,7 +33,7 @@ Le moment est venu de créer les dépôts git pour chaque groupe/étudiant suiva ...@@ -33,7 +33,7 @@ Le moment est venu de créer les dépôts git pour chaque groupe/étudiant suiva
## Utilisation de pwm ## Utilisation de pwm
Ce programme est écrit en python et testé avec la version 3.9.0, avec les dépendances suivantes (voir `requirements.txt`) : Ce programme est écrit en python et testé avec les versions 3.6, 3.7, 3.8 et 3.9, avec les dépendances suivantes (voir `requirements.txt`) :
``` ```
requests requests
......
...@@ -281,7 +281,7 @@ if __name__ == '__main__': ...@@ -281,7 +281,7 @@ if __name__ == '__main__':
'clone', help='Clone the repositories locally') 'clone', help='Clone the repositories locally')
group_clone = parser_clone.add_mutually_exclusive_group() group_clone = parser_clone.add_mutually_exclusive_group()
group_clone.add_argument("-g", "--group", action="store_true", group_clone.add_argument("-g", "--group", action="store_true",
help="Clone repositories from a group (with group_id) or forks of a project (with project_id) (default behavior).") help="Clone repositories from a group (with group_id) (default behavior).")
group_clone.add_argument("-f", "--forks", action="store_true", group_clone.add_argument("-f", "--forks", action="store_true",
help="Clone forks of a project (with project_id).") help="Clone forks of a project (with project_id).")
parser_clone.add_argument( parser_clone.add_argument(
...@@ -295,13 +295,16 @@ if __name__ == '__main__': ...@@ -295,13 +295,16 @@ if __name__ == '__main__':
args = parser.parse_args() args = parser.parse_args()
if not args.token: if not args.token:
if os.path.isfile(path := os.environ.get('HOME') + '/.gitedu_token'): home = os.environ.get('HOME')
with open(path) as file: if home:
token_file = home + '/.gitedu_token'
if os.path.isfile(token_file):
with open(token_file) as file:
args.token = file.read().strip() args.token = file.read().strip()
elif os.environ.get('GITEDU_TOKEN'): elif os.environ.get('GITEDU_TOKEN'):
args.token = os.environ.get('GITEDU_TOKEN') args.token = os.environ.get('GITEDU_TOKEN')
else: else:
print('Error: you must given a token') print('Error: you must give a valid api token. Create a token here: https://gitedu.hesge.ch/profile/personal_access_tokens')
exit(1) exit(1)
args.func(args) args.func(args)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment