mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-25 12:22:28 +03:00
added new util feature and added file receive path to system
This commit is contained in:
parent
521d8bc352
commit
0476871d34
2 changed files with 22 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue