Update system
This commit is contained in:
parent
0e65b3445f
commit
20f0d08c3e
|
@ -1,4 +1,7 @@
|
||||||
# ---> Python
|
# ---> Python
|
||||||
|
|
||||||
|
conf.py
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
0.1.0 [25-Ene-2021]
|
||||||
|
---------------------
|
||||||
|
- Script para actualizar Empresa Libre
|
|
@ -0,0 +1,61 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import logging
|
||||||
|
import shlex
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
LOG_FORMAT = '%(asctime)s - %(levelname)s - %(message)s'
|
||||||
|
LOG_DATE = '%d/%m/%Y %H:%M:%S'
|
||||||
|
logging.addLevelName(logging.ERROR, '\033[1;41mERROR\033[1;0m')
|
||||||
|
logging.addLevelName(logging.DEBUG, '\x1b[33mDEBUG\033[1;0m')
|
||||||
|
logging.addLevelName(logging.INFO, '\x1b[32mINFO\033[1;0m')
|
||||||
|
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT, datefmt=LOG_DATE)
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
PATH_SISTEMA = '/opt/empresa-libre'
|
||||||
|
|
||||||
|
|
||||||
|
def _call(args):
|
||||||
|
cmd = shlex.split(args)
|
||||||
|
result = subprocess.run(cmd, stdout=subprocess.PIPE).stdout.decode()
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def _actualizar():
|
||||||
|
confirm = input('¿Estas seguro de actualizar (escribe si) ? ')
|
||||||
|
if confirm != 'si':
|
||||||
|
msg = 'Proceso de actualización cancelado'
|
||||||
|
log.info(msg)
|
||||||
|
return
|
||||||
|
|
||||||
|
args = f'git -C {PATH_SISTEMA} pull origin master'
|
||||||
|
_call(args)
|
||||||
|
|
||||||
|
msg = 'Sistema actualizado correctamente'
|
||||||
|
log.info(msg)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def main(args):
|
||||||
|
|
||||||
|
if args.actualizar:
|
||||||
|
_actualizar()
|
||||||
|
return
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def _process_command_line_arguments():
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description='Empresa Libre Util')
|
||||||
|
parser.add_argument('-a', '--actualizar', dest='actualizar',
|
||||||
|
action='store_true', default=False, required=False)
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
args = _process_command_line_arguments()
|
||||||
|
main(args)
|
Loading…
Reference in New Issue