Remove ucloud_common and put its files under ucloud.common subpackage.

Remove individual config.py used by every component and put them into single config.py ucloud/config.py
Use /etc/ucloud/ucloud.conf for Environment Variables
Refactoring and a lot of it
Make ucloud repo a package and different components of ucloud a subpackage for avoiding code duplication.
Improved logging.
This commit is contained in:
ahmadbilalkhalid 2019-11-18 22:39:57 +05:00
commit 6fa77bce4d
51 changed files with 890 additions and 567 deletions

View file

@ -1,14 +1,13 @@
import os
import glob
import os
import pathlib
import time
import hashlib
import subprocess as sp
from decouple import config
from etcd3_wrapper import Etcd3Wrapper
import time
from uuid import uuid4
from etcd3_wrapper import Etcd3Wrapper
from config import env_vars
def getxattr(file, attr):
@ -22,7 +21,7 @@ def getxattr(file, attr):
value = value.decode("utf-8")
except sp.CalledProcessError:
value = None
return value
@ -32,8 +31,8 @@ def setxattr(file, attr, value):
attr = "user." + attr
sp.check_output(['setfattr', file,
'--name', attr,
'--value', str(value)])
'--name', attr,
'--value', str(value)])
def sha512sum(file: str):
@ -68,12 +67,13 @@ except Exception as e:
print('Make sure you have getfattr and setfattr available')
exit(1)
def main():
BASE_DIR = config("BASE_DIR")
BASE_DIR = env_vars.get("BASE_DIR")
FILE_PREFIX = config("FILE_PREFIX")
FILE_PREFIX = env_vars.get("FILE_PREFIX")
etcd_client = Etcd3Wrapper(host=config("ETCD_URL"))
etcd_client = Etcd3Wrapper(host=env_vars.get("ETCD_URL"))
# Recursively Get All Files and Folder below BASE_DIR
files = glob.glob("{}/**".format(BASE_DIR), recursive=True)
@ -125,4 +125,4 @@ def main():
if __name__ == "__main__":
main()
main()