mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-25 14:42:22 +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 fcntl
|
||||||
import struct
|
import struct
|
||||||
from uuid import getnode as get_mac
|
from uuid import getnode as get_mac
|
||||||
|
from base.util.util import Util
|
||||||
from base.Scope import Scope
|
from base.Scope import Scope
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,6 +85,13 @@ class System:
|
||||||
def pid_path():
|
def pid_path():
|
||||||
return '/var/run/ahenk.pid'
|
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):
|
class Process(object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -205,6 +213,11 @@ class System:
|
||||||
desktop = system.db_service.select_one_result('session', 'desktop', " username='{0}'".format(username))
|
desktop = system.db_service.select_one_result('session', 'desktop', " username='{0}'".format(username))
|
||||||
return desktop
|
return desktop
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def user_home_path(username):
|
||||||
|
# TODO temp
|
||||||
|
return '/home/{}/'.format(str(username))
|
||||||
|
|
||||||
class Os(object):
|
class Os(object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -11,7 +11,7 @@ import stat
|
||||||
import subprocess
|
import subprocess
|
||||||
import hashlib
|
import hashlib
|
||||||
import datetime
|
import datetime
|
||||||
|
import uuid
|
||||||
|
|
||||||
class Util:
|
class Util:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -81,14 +81,14 @@ class Util:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def read_file(full_path, mode='r'):
|
def read_file(full_path, mode='r'):
|
||||||
file = None
|
content = None
|
||||||
try:
|
try:
|
||||||
file = open(full_path, mode)
|
with open(full_path,mode) as f:
|
||||||
return file.read()
|
content = f.read()
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
file.close()
|
return content
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def write_file(full_path, content, mode='w'):
|
def write_file(full_path, content, mode='w'):
|
||||||
|
@ -239,3 +239,7 @@ class Util:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def timestamp():
|
def timestamp():
|
||||||
return str(datetime.datetime.now().strftime("%d-%m-%Y %I:%M"))
|
return str(datetime.datetime.now().strftime("%d-%m-%Y %I:%M"))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def generate_uuid():
|
||||||
|
return uuid.uuid4()
|
||||||
|
|
Loading…
Reference in a new issue