diff --git a/opt/ahenk/base/system/system.py b/opt/ahenk/base/system/system.py index 3def19e..25e2fa2 100644 --- a/opt/ahenk/base/system/system.py +++ b/opt/ahenk/base/system/system.py @@ -12,6 +12,7 @@ import socket import fcntl import struct from uuid import getnode as get_mac +from base.util.util import Util from base.Scope import Scope @@ -84,6 +85,13 @@ class System: def pid_path(): return '/var/run/ahenk.pid' + @staticmethod + def received_dir_path(): + path = '/tmp/.ahenk/' + if Util.is_exist(path) is False: + Util.create_directory(path) + return path + class Process(object): @staticmethod @@ -205,6 +213,11 @@ class System: desktop = system.db_service.select_one_result('session', 'desktop', " username='{0}'".format(username)) return desktop + @staticmethod + def user_home_path(username): + # TODO temp + return '/home/{}/'.format(str(username)) + class Os(object): @staticmethod diff --git a/opt/ahenk/base/util/util.py b/opt/ahenk/base/util/util.py index dfa62d9..8b390c3 100644 --- a/opt/ahenk/base/util/util.py +++ b/opt/ahenk/base/util/util.py @@ -11,7 +11,7 @@ import stat import subprocess import hashlib import datetime - +import uuid class Util: def __init__(self): @@ -81,14 +81,14 @@ class Util: @staticmethod def read_file(full_path, mode='r'): - file = None + content = None try: - file = open(full_path, mode) - return file.read() + with open(full_path,mode) as f: + content = f.read() except: raise finally: - file.close() + return content @staticmethod def write_file(full_path, content, mode='w'): @@ -239,3 +239,7 @@ class Util: @staticmethod def timestamp(): return str(datetime.datetime.now().strftime("%d-%m-%Y %I:%M")) + + @staticmethod + def generate_uuid(): + return uuid.uuid4()