-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[packaging] removing setup.py and fixing pyproject.toml scripts
- Loading branch information
1 parent
820571a
commit e87079c
Showing
3 changed files
with
72 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,78 +21,83 @@ def print_output(text): | |
for line in text.strip('\n').split('\n'): | ||
print('\t' + line) | ||
|
||
# Change current dir for source file dir | ||
scriptdir = os.path.dirname(os.path.abspath(__file__)) | ||
os.chdir(scriptdir) | ||
|
||
# Open configuration file | ||
try: | ||
config = json.load(open(os.environ.get('INGINIOUS_SYNC_CONFIG', 'synchronize.json'), 'r')) | ||
maindir = os.path.abspath(config['maindir']) | ||
print('\x1b[33;1m-> Synchronization dir. : ' + maindir + ' \033[0m') | ||
except: | ||
print('\x1b[31;1mERROR: Failed to load configuration file\033[0m') | ||
exit(1) | ||
|
||
# Configure git | ||
try: | ||
git.config("--global", "user.name", "INGInious") | ||
git.config("--global", "user.email", "[email protected]") | ||
except: | ||
print('\x1b[31;1mERROR: Failed to configure Git. Is Git installed ?\033[0m') | ||
exit(1) | ||
|
||
for repo in config['repos']: | ||
print('\x1b[33;1m-> Synchronizing course repository : ' + repo['course'] + ' \033[0m') | ||
# Add private key with ssh add | ||
print('\x1b[1m--> Add private key with ssh-add \033[0m') | ||
|
||
def main(): | ||
# Change current dir for source file dir | ||
scriptdir = os.path.dirname(os.path.abspath(__file__)) | ||
os.chdir(scriptdir) | ||
|
||
# Open configuration file | ||
try: | ||
out = ssh_add(os.path.abspath(repo['keyfile'])) | ||
print_output(out.stderr.decode('utf-8')) | ||
config = json.load(open(os.environ.get('INGINIOUS_SYNC_CONFIG', 'synchronize.json'), 'r')) | ||
maindir = os.path.abspath(config['maindir']) | ||
print('\x1b[33;1m-> Synchronization dir. : ' + maindir + ' \033[0m') | ||
except: | ||
print('\x1b[31;1mERROR: Failed to load keyfile, or to add it with ssh-add\033[0m') | ||
print('\x1b[31;1mERROR: Failed to load configuration file\033[0m') | ||
exit(1) | ||
|
||
|
||
# Check if repo must be cloned | ||
if not os.path.exists(maindir + "/" + repo['course']): | ||
print('\x1b[33;1m--> Cloning repository\033[0m') | ||
out = git.clone(repo['url'], maindir + "/" + repo['course']) | ||
print_output(out.stdout.decode('utf-8')) | ||
else: | ||
print('\x1b[1m--> Synchronizing repository\033[0m') | ||
|
||
# Change working dir to the repo path | ||
os.chdir(maindir + "/" + repo['course']) | ||
|
||
# Add all the files to git and commit | ||
out = git.add("-A", '.') | ||
|
||
# Check for something to commit | ||
if git.status('-s'): | ||
out = git.commit("-a", "-m", "Automatic synchronization from INGInious") | ||
|
||
# Configure git | ||
try: | ||
git.config("--global", "user.name", "INGInious") | ||
git.config("--global", "user.email", "[email protected]") | ||
except: | ||
print('\x1b[31;1mERROR: Failed to configure Git. Is Git installed ?\033[0m') | ||
exit(1) | ||
|
||
for repo in config['repos']: | ||
print('\x1b[33;1m-> Synchronizing course repository : ' + repo['course'] + ' \033[0m') | ||
# Add private key with ssh add | ||
print('\x1b[1m--> Add private key with ssh-add \033[0m') | ||
os.chdir(scriptdir) | ||
try: | ||
out = ssh_add(os.path.abspath(repo['keyfile'])) | ||
print_output(out.stderr.decode('utf-8')) | ||
except: | ||
print('\x1b[31;1mERROR: Failed to load keyfile, or to add it with ssh-add\033[0m') | ||
exit(1) | ||
|
||
|
||
# Check if repo must be cloned | ||
if not os.path.exists(maindir + "/" + repo['course']): | ||
print('\x1b[33;1m--> Cloning repository\033[0m') | ||
out = git.clone(repo['url'], maindir + "/" + repo['course']) | ||
print_output(out.stdout.decode('utf-8')) | ||
else: | ||
print('\x1b[1m--> Synchronizing repository\033[0m') | ||
|
||
# Change working dir to the repo path | ||
os.chdir(maindir + "/" + repo['course']) | ||
|
||
# Add all the files to git and commit | ||
out = git.add("-A", '.') | ||
|
||
# Check for something to commit | ||
if git.status('-s'): | ||
out = git.commit("-a", "-m", "Automatic synchronization from INGInious") | ||
print_output(out.stdout.decode('utf-8')) | ||
print_output(out.stderr.decode('utf-8')) | ||
if not out.exit_code == 0: | ||
exit(1) | ||
|
||
|
||
# Pull recursively, keeping the INGInious version of changes | ||
out = git.pull("--no-edit","-s", "recursive", "-X", "theirs") | ||
print_output(out.stdout.decode('utf-8')) | ||
print_output(out.stderr.decode('utf-8')) | ||
if not out.exit_code == 0: | ||
exit(1) | ||
|
||
|
||
# Pull recursively, keeping the INGInious version of changes | ||
out = git.pull("--no-edit","-s", "recursive", "-X", "theirs") | ||
print_output(out.stdout.decode('utf-8')) | ||
# Push | ||
if repo.get("push", True): | ||
out = git.push() | ||
|
||
# Remove private key with ssh add | ||
print('\x1b[1m--> Remove private key with ssh-add \033[0m') | ||
os.chdir(scriptdir) | ||
out = ssh_add("-d", os.path.abspath(repo['keyfile'])) | ||
print_output(out.stderr.decode('utf-8')) | ||
if not out.exit_code == 0: | ||
exit(1) | ||
|
||
# Push | ||
if repo.get("push", True): | ||
out = git.push() | ||
|
||
# Remove private key with ssh add | ||
print('\x1b[1m--> Remove private key with ssh-add \033[0m') | ||
os.chdir(scriptdir) | ||
out = ssh_add("-d", os.path.abspath(repo['keyfile'])) | ||
print_output(out.stderr.decode('utf-8')) | ||
if not out.exit_code == 0: | ||
exit(1) | ||
|
||
if __name__ == "__main__": | ||
main() |