From 7b6532f1185a2541d450d224c4fc747b2b54cb2d Mon Sep 17 00:00:00 2001 From: VirtuBox Date: Tue, 17 Sep 2019 01:30:58 +0200 Subject: [PATCH] Split setup.py in two file to redirect logs --- gitconfig.py | 34 ++++++++++++++++++++++++++++++++++ install | 10 +++------- setup.py | 38 +++----------------------------------- wo/core/variables.py | 2 +- 4 files changed, 41 insertions(+), 43 deletions(-) create mode 100644 gitconfig.py diff --git a/gitconfig.py b/gitconfig.py new file mode 100644 index 0000000..65ef8e2 --- /dev/null +++ b/gitconfig.py @@ -0,0 +1,34 @@ +import configparser +import os +import re +import shutil + +# WordOps git configuration management +config = configparser.ConfigParser() +config.read(os.path.expanduser("~")+'/.gitconfig') +try: + wo_user = config['user']['name'] + wo_email = config['user']['email'] +except Exception: + print("WordOps (wo) require an username & and an email " + "address to configure Git (used to save server configurations)") + print("Your informations will ONLY be stored locally") + + wo_user = input("Enter your name: ") + while wo_user == "": + print("Unfortunately, this can't be left blank") + wo_user = input("Enter your name: ") + + wo_email = input("Enter your email: ") + + while not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", + wo_email): + print("Whoops, seems like you made a typo - " + "the e-mailaddress is invalid...") + wo_email = input("Enter your email: ") + + os.system("git config --global user.name {0}".format(wo_user)) + os.system("git config --global user.email {0}".format(wo_email)) + +if not os.path.isfile('/root/.gitconfig'): + shutil.copy2(os.path.expanduser("~")+'/.gitconfig', '/root/.gitconfig') diff --git a/install b/install index 49ee625..3bf236a 100755 --- a/install +++ b/install @@ -462,13 +462,9 @@ wo_install() { [ ! -f "$HOME/.gitconfig" ] && { bash -c 'echo -e "[user]\n\tname = $USER\n\temail = root@$HOSTNAME.local" > $HOME/.gitconfig'; } fi - if [ -f "$HOME/.gitconfig" ]; then - # install and redirect log to not print python package install - python3 setup.py install >> $wo_install_log 2>&1 - else - # install without redirecting logs to prompt user for name & email - python3 setup.py install - fi + # install and redirect log to not print python package install + python3 gitconfig.py + python3 setup.py install >> $wo_install_log 2>&1 } diff --git a/setup.py b/setup.py index 66e548f..8b3b270 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,8 @@ -from setuptools import setup, find_packages -import os import glob -import configparser -import re -import shutil +import os + +from setuptools import find_packages, setup conf = [] templates = [] @@ -26,36 +24,6 @@ if not os.path.exists('/var/log/wo/'): if not os.path.exists('/var/lib/wo/'): os.makedirs('/var/lib/wo/') -# WordOps git configuration management -config = configparser.ConfigParser() -config.read(os.path.expanduser("~")+'/.gitconfig') -try: - wo_user = config['user']['name'] - wo_email = config['user']['email'] -except Exception: - print("WordOps (wo) require an username & and an email " - "address to configure Git (used to save server configurations)") - print("Your informations will ONLY be stored locally") - - wo_user = input("Enter your name: ") - while wo_user == "": - print("Unfortunately, this can't be left blank") - wo_user = input("Enter your name: ") - - wo_email = input("Enter your email: ") - - while not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", - wo_email): - print("Whoops, seems like you made a typo - " - "the e-mailaddress is invalid...") - wo_email = input("Enter your email: ") - - os.system("git config --global user.name {0}".format(wo_user)) - os.system("git config --global user.email {0}".format(wo_email)) - -if not os.path.isfile('/root/.gitconfig'): - shutil.copy2(os.path.expanduser("~")+'/.gitconfig', '/root/.gitconfig') - setup(name='wo', version='3.9.8.11', description=long_description, diff --git a/wo/core/variables.py b/wo/core/variables.py index fb3dd39..fb7b664 100644 --- a/wo/core/variables.py +++ b/wo/core/variables.py @@ -13,7 +13,7 @@ class WOVariables(): # WordOps version wo_version = "3.9.8.11" # WordOps packages versions - wo_wp_cli = "2.2.0" + wo_wp_cli = "2.3.0" wo_adminer = "4.7.2" wo_phpmyadmin = "4.9.0.1" wo_extplorer = "2.1.13"