mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-12-23 19:12:16 +03:00
Little Bug fixings in system.py aand ssh_file_transfer.py, also utility in util.py called install_package
This commit is contained in:
parent
c0598f608c
commit
cda00f2810
4 changed files with 22 additions and 5 deletions
|
@ -40,7 +40,6 @@ class Ssh(object):
|
|||
try:
|
||||
sftp.chdir(self.target_path) # Test if remote_path exists
|
||||
except IOError:
|
||||
print(self.target_path)
|
||||
sftp.mkdir(self.target_path) # Create remote_path
|
||||
sftp.chdir(self.target_path)
|
||||
|
||||
|
|
|
@ -41,6 +41,13 @@ class System:
|
|||
config.read(System.Ahenk.config_path())
|
||||
return config.get('BASE', 'dbPath')
|
||||
|
||||
@staticmethod
|
||||
def uid():
|
||||
config = configparser.ConfigParser()
|
||||
config._interpolation = configparser.ExtendedInterpolation()
|
||||
config.read(System.Ahenk.config_path())
|
||||
return config.get('CONNECTION', 'uid')
|
||||
|
||||
@staticmethod
|
||||
def plugins_path():
|
||||
config = configparser.ConfigParser()
|
||||
|
@ -89,7 +96,7 @@ class System:
|
|||
def received_dir_path():
|
||||
path = '/tmp/.ahenk/'
|
||||
if Util.is_exist(path) is False:
|
||||
#TODO write permission add
|
||||
# TODO write permission add
|
||||
Util.create_directory(path)
|
||||
return path
|
||||
|
||||
|
@ -330,7 +337,8 @@ class System:
|
|||
for iface in psutil.net_io_counters(pernic=True):
|
||||
f = os.popen('ifconfig {} | grep "inet\ addr" | cut -d: -f2 | cut -d" " -f1'.format(iface))
|
||||
ip = str(f.read()).replace('\n', '')
|
||||
if re.match(r'^((\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])$', ip) and str(ip) != 'localhost' and str(ip) != '127.0.0.1':
|
||||
if re.match(r'^((\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])$',
|
||||
ip) and str(ip) != 'localhost' and str(ip) != '127.0.0.1':
|
||||
arr.append(ip)
|
||||
return arr
|
||||
|
||||
|
@ -355,7 +363,8 @@ class System:
|
|||
try:
|
||||
addr_list = psutil.net_if_addrs()
|
||||
mac = addr_list[str(iface)][2][1]
|
||||
if re.match("[0-9a-f]{2}([-:])[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", mac.lower()) and str(mac) != '00:00:00:00:00:00':
|
||||
if re.match("[0-9a-f]{2}([-:])[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", mac.lower()) and str(
|
||||
mac) != '00:00:00:00:00:00':
|
||||
arr.append(mac.lower())
|
||||
except Exception as e:
|
||||
pass
|
||||
|
@ -371,7 +380,8 @@ class System:
|
|||
arr = []
|
||||
for iface in psutil.net_io_counters(pernic=True):
|
||||
ip = psutil.net_if_addrs()[str(iface)][0][1]
|
||||
if re.match(r'^((\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])$', ip) and str(ip) != 'localhost' and str(ip) != '127.0.0.1':
|
||||
if re.match(r'^((\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])$', ip) and str(
|
||||
ip) != 'localhost' and str(ip) != '127.0.0.1':
|
||||
arr.append(ip)
|
||||
return arr
|
||||
|
||||
|
|
|
@ -255,3 +255,10 @@ class Util:
|
|||
if attr_name in j:
|
||||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def install_package(package_name, package_version):
|
||||
command = "sudo apt-get --yes --force-yes install {0}={1}".format(package_name, package_version)
|
||||
result_code, p_out, p_err = Util.execute(command)
|
||||
return result_code, p_out, p_err
|
||||
|
||||
|
|
1
opt/ahenk/plugins/package-manager
Symbolic link
1
opt/ahenk/plugins/package-manager
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/cemre/git/lider-ahenk-package-manager-plugin/ahenk-package-manager/package-manager
|
Loading…
Reference in a new issue