Avoid os.system and use resource friendly eConsoleAppContainer
authorAthanasios Oikonomou <athoik@gmail.com>
Wed, 30 Dec 2015 12:48:33 +0000 (14:48 +0200)
committerMike Looijmans <milo@openpli.org>
Wed, 30 Dec 2015 14:26:33 +0000 (15:26 +0100)
Also change import of os_path into os.path in Wlan.py

Finally use python to write "/proc/sys/vm/drop_caches" instead of forking shell to do that.

Signed-off-by: Mike Looijmans <milo@openpli.org>

lib/python/Plugins/SystemPlugins/NetworkWizard/NetworkWizard.py
lib/python/Plugins/SystemPlugins/WirelessLan/Wlan.py
lib/python/Screens/About.py

index 9d2a75d..a7c9b5c 100755 (executable)
@@ -7,7 +7,8 @@ from Components.Sources.Boolean import Boolean
 from Components.Network import iNetwork
 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
 from enigma import eTimer
-from os import system
+
+import enigma
 
 class NetworkWizard(WizardLanguage, Rc):
        skin = """
@@ -128,7 +129,7 @@ class NetworkWizard(WizardLanguage, Rc):
                                if interface == self.selectedInterface:
                                        if self.originalInterfaceState[interface]["up"] is False:
                                                if iNetwork.checkforInterface(interface) is True:
-                                                       system("ifconfig " + interface + " down")
+                                                       enigma.eConsoleAppContainer().execute("ifconfig %s down" % interface)
 
        def listInterfaces(self):
                self.checkOldInterfaceState()
index fc91e95..50db9b4 100644 (file)
@@ -2,10 +2,12 @@ from Components.config import config, ConfigYesNo, NoSave, ConfigSubsection, Con
 from Components.Console import Console
 from Components.Network import iNetwork
 
-from os import system, path as os_path
-from string import maketrans, strip
+import enigma
+
+import os
 import sys
 import types
+from string import maketrans, strip
 from re import compile as re_compile, search as re_search, escape as re_escape
 from pythonwifi.iwlibs import getNICnames, Wireless, Iwfreq, getWNICnames
 from pythonwifi import flags as wififlags
@@ -65,7 +67,7 @@ class Wlan:
                if self.oldInterfaceState is False:
                        if iNetwork.getAdapterAttribute(self.iface, "up") is False:
                                iNetwork.setAdapterAttribute(self.iface, "up", True)
-                               system("ifconfig "+self.iface+" up")
+                               enigma.eConsoleAppContainer().execute("ifconfig %s up" % self.iface)
 
                ifobj = Wireless(self.iface) # a Wireless NIC Object
 
@@ -122,7 +124,7 @@ class Wlan:
                if self.oldInterfaceState is not None:
                        if self.oldInterfaceState is False:
                                iNetwork.setAdapterAttribute(self.iface, "up", False)
-                               system("ifconfig "+self.iface+" down")
+                               enigma.eConsoleAppContainer().execute("ifconfig %s down" % self.iface)
                                self.oldInterfaceState = None
                                self.iface = None
 
@@ -180,7 +182,7 @@ class wpaSupplicant:
 
        def loadConfig(self,iface):
                configfile = getWlanConfigName(iface)
-               if not os_path.exists(configfile):
+               if not os.path.exists(configfile):
                        configfile = '/etc/wpa_supplicant.conf'
                try:
                        #parse the wpasupplicant configfile
index a3fdf6c..c99408f 100644 (file)
@@ -12,7 +12,7 @@ from Components.Label import Label
 from Components.ProgressBar import ProgressBar
 
 from Tools.StbHardware import getFPVersion
-from enigma import eTimer, eLabel
+from enigma import eTimer, eLabel, eConsoleAppContainer
 
 from Components.HTMLComponent import HTMLComponent
 from Components.GUIComponent import GUIComponent
@@ -284,9 +284,8 @@ class MemoryInfo(Screen):
                        print "[About] getMemoryInfo FAIL:", e
 
        def clearMemory(self):
-               from os import system
-               system("sync")
-               system("echo 3 > /proc/sys/vm/drop_caches")
+               eConsoleAppContainer().execute("sync")
+               open("/proc/sys/vm/drop_caches", "w").write("3")
                self.getMemoryInfo()
 
 class MemoryInfoSkinParams(HTMLComponent, GUIComponent):