# -*- coding: utf-8 -*-\r
# for localized messages\r
from __init__ import _\r
-from re import compile as re_compile, search as re_search\r
-from os import system, popen, path as os_path, listdir, mkdir, rmdir, makedirs\r
+from re import compile as re_compile\r
+from os import path as os_path, mkdir, rmdir\r
\r
-from enigma import eTimer, eConsoleAppContainer\r
+from enigma import eTimer\r
from Components.Console import Console\r
-from Components.Harddisk import harddiskmanager #global harddiskmanager\r
+from Components.Harddisk import harddiskmanager #global harddiskmanager\r
\r
from xml.etree.cElementTree import parse as cet_parse\r
\r
self.timer = eTimer()\r
self.timer.callback.append(self.mountTimeout)\r
\r
-\r
self.getAutoMountPoints()\r
\r
def getAutoMountPoints(self, callback = None):\r
automounts = []\r
self.automounts = {}\r
self.activeMountsCounter = 0\r
- \r
+\r
if not os_path.exists(XML_FSTAB):\r
return\r
tree = cet_parse(XML_FSTAB).getroot()\r
# Read out NFS Mounts\r
for nfs in tree.findall("nfs"):\r
for mount in nfs.findall("mount"):\r
- data = { 'isMounted': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype' : False, 'options' : False } \r
+ data = { 'isMounted': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype' : False, 'options' : False }\r
try:\r
data['mounttype'] = 'nfs'.encode("UTF-8")\r
data['active'] = getValue(mount.findall("active"), False).encode("UTF-8")\r
data['sharename'] = getValue(mount.findall("sharename"), "MEDIA").encode("UTF-8")\r
data['options'] = getValue(mount.findall("options"), "rw,nolock").encode("UTF-8")\r
print "NFSMOUNT",data\r
- self.automounts[data['sharename']] = data \r
+ self.automounts[data['sharename']] = data\r
except Exception, e:\r
print "[MountManager] Error reading Mounts:", e\r
# Read out CIFS Mounts\r
for nfs in tree.findall("cifs"):\r
for mount in nfs.findall("mount"):\r
- data = { 'isMounted': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype' : False, 'options' : False } \r
+ data = { 'isMounted': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype' : False, 'options' : False }\r
try:\r
data['mounttype'] = 'cifs'.encode("UTF-8")\r
data['active'] = getValue(mount.findall("active"), False).encode("UTF-8")\r
data['username'] = getValue(mount.findall("username"), "guest").encode("UTF-8")\r
data['password'] = getValue(mount.findall("password"), "").encode("UTF-8")\r
print "CIFSMOUNT",data\r
- self.automounts[data['sharename']] = data \r
+ self.automounts[data['sharename']] = data\r
except Exception, e:\r
print "[MountManager] Error reading Mounts:", e\r
\r
print "[AutoMount.py] -getAutoMountPoints:self.automounts -->",self.automounts\r
if len(self.automounts) == 0:\r
- print "[AutoMount.py] self.automounts without mounts",self.automounts\r
+ print "[AutoMount.py] self.automounts without mounts",self.automounts\r
if callback is not None:\r
callback(True)\r
else:\r
for sharename, sharedata in self.automounts.items():\r
- self.CheckMountPoint(sharedata, callback) \r
+ self.CheckMountPoint(sharedata, callback)\r
\r
def CheckMountPoint(self, data, callback):\r
print "[AutoMount.py] CheckMountPoint"\r
print "[AutoMount.py] activeMounts:--->",self.activeMountsCounter\r
if not self.MountConsole:\r
self.MountConsole = Console()\r
- \r
+\r
self.command = None\r
if self.activeMountsCounter == 0:\r
print "self.automounts without active mounts",self.automounts\r
if data['active'] == 'False' or data['active'] is False:\r
path = '/media/net/'+ data['sharename']\r
self.command = 'umount -f '+ path\r
- \r
+\r
if data['active'] == 'True' or data['active'] is True:\r
path = '/media/net/'+ data['sharename']\r
if os_path.exists(path) is False:\r
if tmpsharedir[-1:] == "$":\r
tmpdir = tmpsharedir.replace("$", "\\$")\r
tmpsharedir = tmpdir\r
- \r
+\r
if data['mounttype'] == 'nfs':\r
if not os_path.ismount(path):\r
tmpcmd = 'mount -t nfs -o tcp,'+ data['options'] +',rsize=8192,wsize=8192 ' + data['ip'] + ':' + tmpsharedir + ' ' + path\r
self.command = tmpcmd.encode("UTF-8")\r
- \r
+\r
if data['mounttype'] == 'cifs':\r
if not os_path.ismount(path):\r
tmpusername = data['username'].replace(" ", "\\ ")\r
self.MountConsole.ePopen(self.command, self.CheckMountPointFinished, [data, callback])\r
else:\r
self.CheckMountPointFinished(None,None, [data, callback])\r
- \r
+\r
def CheckMountPointFinished(self, result, retval, extra_args):\r
print "[AutoMount.py] CheckMountPointFinished"\r
print "[AutoMount.py] result",result\r
if not os_path.ismount(path):\r
rmdir(path)\r
harddiskmanager.removeMountedPartition(path)\r
- \r
+\r
if self.MountConsole:\r
if len(self.MountConsole.appContainers) == 0:\r
if callback is not None:\r
def mountTimeout(self):\r
self.timer.stop()\r
if self.MountConsole:\r
- if len(self.MountConsole.appContainers) == 0: \r
+ if len(self.MountConsole.appContainers) == 0:\r
print "self.automounts after mounting",self.automounts\r
if self.callback is not None:\r
self.callback(True)\r
self.MountConsole = Console()\r
self.activeMountsCounter = 0\r
self.getAutoMountPoints()\r
- \r
+\r
# helper function\r
def regExpMatch(self, pattern, string):\r
if string is None:\r
fp.close()\r
except:\r
print "[AutoMount.py] /etc/auto.network - opening failed"\r
- \r
+\r
ipRegexp = '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'\r
cifsIpLinePattern = re_compile('://' + ipRegexp + '/')\r
nfsIpLinePattern = re_compile(ipRegexp + ':/')\r
if len(split) == 2 and split[0][0] == '*':\r
continue\r
if len(split) == 3:\r
- data = { 'isMounted': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype' : False, 'options' : False } \r
+ data = { 'isMounted': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype' : False, 'options' : False }\r
currshare = ""\r
if split[0][0] == '#':\r
data['active'] = False\r
data['active'] = True\r
self.activeMountsCounter +=1\r
currshare = split[0]\r
- data['sharename'] = currshare \r
+ data['sharename'] = currshare\r
if '-fstype=cifs' in split[1]:\r
data['mounttype'] = 'cifs'\r
options = split[1][split[1].index('-fstype=cifs')+13 : split[1].index(',user=')]\r
tmpdir = tmpsharedir.replace("\$", "$")\r
tmpsharedir = tmpdir\r
data['sharedir'] = tmpsharedir\r
- \r
+\r
if '-fstype=nfs' in split[1]:\r
data['mounttype'] = 'nfs'\r
options = split[1][split[1].index('-fstype=nfs')+12 : ]\r
tmpdir = tmpsharedir.replace("\$", "$")\r
tmpsharedir = tmpdir\r
data['sharedir'] = tmpsharedir\r
- \r
- self.automounts[currshare] = data \r
+\r
+ self.automounts[currshare] = data\r
if len(self.automounts) == 0:\r
- print "[AutoMount.py] self.automounts without mounts",self.automounts\r
+ print "[AutoMount.py] self.automounts without mounts",self.automounts\r
if callback is not None:\r
callback(True)\r
else:\r
#print "automounts",self.automounts\r
for sharename, sharedata in self.automounts.items():\r
- self.CheckMountPoint(sharedata, callback) \r
+ self.CheckMountPoint(sharedata, callback)\r
\r
def CheckMountPoint(self, data, callback):\r
print "[AutoMount.py] CheckMountPoint"\r
if self.activeMountsCounter == 0:\r
#if data['active'] is False:\r
if self.MountConsole:\r
- if len(self.MountConsole.appContainers) == 0: \r
+ if len(self.MountConsole.appContainers) == 0:\r
print "self.automounts without active mounts",self.automounts\r
if callback is not None:\r
callback(True)\r
print "[AutoMount.py] cifscmd--->",cifscmd\r
self.MountConsole.ePopen(cifscmd, self.CheckMountPointFinished, [data, callback])\r
\r
-\r
- \r
def CheckMountPointFinished(self, result, retval, extra_args):\r
print "[AutoMount.py] CheckMountPointFinished"\r
(data, callback ) = extra_args\r
if self.automounts.has_key(data['sharename']):\r
self.automounts[data['sharename']]['isMounted'] = False\r
umountcmd = 'umount /tmp/'+ data['sharename']\r
- self.MountConsole.ePopen(umountcmd, self.CleanMountPointFinished, [data, callback]) \r
+ self.MountConsole.ePopen(umountcmd, self.CleanMountPointFinished, [data, callback])\r
\r
def CleanMountPointFinished(self, result, retval, extra_args):\r
print "[AutoMount.py] CleanMountPointFinished"\r
if os_path.exists(path):\r
rmdir(path)\r
if self.MountConsole:\r
- if len(self.MountConsole.appContainers) == 0: \r
+ if len(self.MountConsole.appContainers) == 0:\r
print "self.automounts after mountcheck",self.automounts\r
if callback is not None:\r
callback(True)\r
tmpdir = tmpsharedir.replace("$", "\\$")\r
tmpsharedir = tmpdir\r
fp.write( tmpsharedir + "\n")\r
- fp.write("\n") \r
+ fp.write("\n")\r
fp.close()\r
\r
def restartAutoFS(self,callback = None):\r
self.commands.append("rm -rf /var/run/autofs")\r
self.commands.append("/etc/init.d/autofs start")\r
self.restartConsole.eBatch(self.commands, self.restartAutoFSFinished, callback, debug=True)\r
- \r
+\r
def restartAutoFSFinished(self,extra_args):\r
print "[AutoMount.py] restartAutoFSFinished "\r
( callback ) = extra_args\r
from Screens.VirtualKeyBoard import VirtualKeyBoard
from Components.ActionMap import ActionMap
from Components.Button import Button
-from Components.config import config, ConfigYesNo, ConfigIP, NoSave, ConfigText, ConfigEnableDisable, ConfigPassword, ConfigSelection, getConfigListEntry, ConfigNothing
+from Components.config import config, ConfigIP, NoSave, ConfigText, ConfigEnableDisable, ConfigPassword, ConfigSelection, getConfigListEntry
from Components.ConfigList import ConfigListScreen
-from Components.Label import Label,MultiColorLabel
-from Components.Pixmap import Pixmap,MultiPixmap
+from Components.Label import Label
+from Components.Pixmap import Pixmap
from Components.ActionMap import ActionMap, NumberActionMap
-from enigma import eTimer, ePoint, eSize, RT_HALIGN_LEFT, eListboxPythonMultiContent, gFont
+from enigma import ePoint
from AutoMount import iAutoMount, AutoMount
class AutoMountEdit(Screen, ConfigListScreen):
<widget name="ButtonRedtext" position="410,365" size="140,21" zPosition="10" font="Regular;21" transparent="1" />
<widget name="ButtonRed" pixmap="skin_default/buttons/button_red.png" position="390,365" zPosition="10" size="15,16" transparent="1" alphatest="on" />
<widget name="VKeyIcon" pixmap="skin_default/vkey_icon.png" position="40,345" zPosition="10" size="60,48" transparent="1" alphatest="on" />
- <widget name="HelpWindow" pixmap="skin_default/vkey_icon.png" position="175,325" zPosition="1" size="1,1" transparent="1" alphatest="on" />
+ <widget name="HelpWindow" pixmap="skin_default/vkey_icon.png" position="175,325" zPosition="1" size="1,1" transparent="1" alphatest="on" />
<ePixmap pixmap="skin_default/bottombar.png" position="10,310" size="540,120" zPosition="1" transparent="1" alphatest="on" />
</screen>"""
self.mountinfo = mountinfo
if self.mountinfo is None:
#Initialize blank mount enty
- self.mountinfo = { 'isMounted': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype' : False, 'options' : False }
-
+ self.mountinfo = { 'isMounted': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype' : False, 'options' : False }
+
self.applyConfigRef = None
self.updateConfigRef = None
self.mounts = iAutoMount.getMountsList()
self.createConfig()
-
+
self["actions"] = NumberActionMap(["SetupActions"],
{
"ok": self.ok,
"cancel": self.close,
"red": self.close,
}, -2)
-
+
self["VirtualKB"] = ActionMap(["ShortcutActions"],
{
"green": self.KeyGreen,
def layoutFinished(self):
- self.setTitle(_("Mounts editor"))
+ self.setTitle(_("Mounts editor"))
self["ButtonGreen"].hide()
self["VKeyIcon"].hide()
self["VirtualKB"].setEnabled(False)
self.optionsEntry = None
self.usernameEntry = None
self.passwordEntry = None
-
+
self.sharetypelist = []
self.sharetypelist.append(("nfs", _("NFS share")))
- self.sharetypelist.append(("cifs", _("CIFS share")))
+ self.sharetypelist.append(("cifs", _("CIFS share")))
if self.mountinfo.has_key('mounttype'):
mounttype = self.mountinfo['mounttype']
else:
mounttype = "nfs"
-
+
if self.mountinfo.has_key('active'):
active = self.mountinfo['active']
if active == 'True':
active = True
if active == 'False':
- active = False
+ active = False
else:
active = True
if self.mountinfo.has_key('ip'):
else:
ip = self.convertIP(self.mountinfo['ip'])
else:
- ip = [192, 168, 0, 0]
+ ip = [192, 168, 0, 0]
if self.mountinfo.has_key('sharename'):
sharename = self.mountinfo['sharename']
else:
- sharename = "Sharename"
+ sharename = "Sharename"
if self.mountinfo.has_key('sharedir'):
sharedir = self.mountinfo['sharedir']
else:
if username is False:
username = ""
if password is False:
- password = ""
+ password = ""
if mounttype is False:
mounttype = "nfs"
-
+
self.activeConfigEntry = NoSave(ConfigEnableDisable(default = active))
self.ipConfigEntry = NoSave(ConfigIP(default = ip))
self.sharenameConfigEntry = NoSave(ConfigText(default = sharename, visible_width = 50, fixed_size = False))
self.usernameConfigEntry = NoSave(ConfigText(default = username, visible_width = 50, fixed_size = False))
self.passwordConfigEntry = NoSave(ConfigPassword(default = password, visible_width = 50, fixed_size = False))
self.mounttypeConfigEntry = NoSave(ConfigSelection(self.sharetypelist, default = mounttype ))
-
+
def createSetup(self):
self.list = []
self.activeEntry = getConfigListEntry(_("Active"), self.activeConfigEntry)
self.list.append(self.activeEntry)
self.sharenameEntry = getConfigListEntry(_("Local share name"), self.sharenameConfigEntry)
- self.list.append(self.sharenameEntry)
+ self.list.append(self.sharenameEntry)
self.mounttypeEntry = getConfigListEntry(_("Mount type"), self.mounttypeConfigEntry)
- self.list.append(self.mounttypeEntry)
+ self.list.append(self.mounttypeEntry)
self.ipEntry = getConfigListEntry(_("Server IP"), self.ipConfigEntry)
self.list.append(self.ipEntry)
self.sharedirEntry = getConfigListEntry(_("Server share"), self.sharedirConfigEntry)
def newConfig(self):
if self["config"].getCurrent() == self.mounttypeEntry:
self.createSetup()
-
+
def KeyGreen(self):
print "Green Pressed"
if self["config"].getCurrent() == self.sharenameEntry:
if self["config"].getCurrent() == self.passwordEntry:
self.session.openWithCallback(lambda x : self.VirtualKeyBoardCallback(x, 'password'), VirtualKeyBoard, title = (_("Enter password:")), text = self.passwordConfigEntry.value)
-
def VirtualKeyBoardCallback(self, callback = None, entry = None):
if callback is not None and len(callback) and entry is not None and len(entry):
if entry == 'sharename':
iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "sharename", self.sharenameConfigEntry.value)
iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "active", self.activeConfigEntry.value)
iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "ip", self.ipConfigEntry.getText())
- iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "sharedir", self.sharedirConfigEntry.value)
+ iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "sharedir", self.sharedirConfigEntry.value)
iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "mounttype", self.mounttypeConfigEntry.value)
iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "options", self.optionsConfigEntry.value)
iAutoMount.setMountsAttribute(self.sharenameConfigEntry.value, "username", self.usernameConfigEntry.value)
data['active'] = self.activeConfigEntry.value
data['ip'] = self.ipConfigEntry.getText()
data['sharename'] = self.sharenameConfigEntry.value
- data['sharedir'] = self.sharedirConfigEntry.value
+ data['sharedir'] = self.sharedirConfigEntry.value
data['options'] = self.optionsConfigEntry.value
data['mounttype'] = self.mounttypeConfigEntry.value
data['username'] = self.usernameConfigEntry.value
data['password'] = self.passwordConfigEntry.value
self.applyConfigRef = None
self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network mount..."), type = MessageBox.TYPE_INFO, enable_input = False)
- iAutoMount.automounts[self.sharenameConfigEntry.value] = data
+ iAutoMount.automounts[self.sharenameConfigEntry.value] = data
iAutoMount.writeMountsConfig()
- iAutoMount.getAutoMountPoints(self.applyConfigDataAvail)
+ iAutoMount.getAutoMountPoints(self.applyConfigDataAvail)
else:
self.close()
def applyConfigDataAvail(self, data):
if data is True:
self.applyConfigRef.close(True)
-
+
def applyConfigfinishedCB(self,data):
if data is True:
self.session.openWithCallback(self.applyfinished, MessageBox, _("Your network mount has been activated."), type = MessageBox.TYPE_INFO, timeout = 10)
-
+
def applyfinished(self,data):
if data is not None:
if data is True:
from Screens.Screen import Screen\r
from Screens.MessageBox import MessageBox\r
from Screens.VirtualKeyBoard import VirtualKeyBoard\r
-from enigma import loadPNG, eListboxPythonMultiContent, gFont, eTimer\r
from Components.Label import Label\r
from Components.Pixmap import Pixmap\r
from Components.ActionMap import ActionMap\r
-from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest\r
from Components.Network import iNetwork\r
from Components.Sources.List import List\r
from Tools.LoadPixmap import LoadPixmap\r
from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE\r
-from os import system, popen, path as os_path, listdir\r
+from os import path as os_path\r
\r
from MountView import AutoMountView\r
from MountEdit import AutoMountEdit\r
from AutoMount import iAutoMount, AutoMount\r
from UserManager import UserManager\r
\r
-\r
class AutoMountManager(Screen):\r
skin = """\r
<screen name="AutoMountManager" position="90,140" size="560,350" title="AutoMountManager">\r
self["ButtonRed"] = Pixmap()\r
self["ButtonRedtext"] = Label(_("Close"))\r
self["introduction"] = Label(_("Press OK to select."))\r
- \r
+\r
self.list = []\r
self["config"] = List(self.list)\r
self.updateList()\r
- self.onClose.append(self.cleanup) \r
+ self.onClose.append(self.cleanup)\r
self.onShown.append(self.setWindowTitle)\r
\r
def setWindowTitle(self):\r
self.setTitle(_("MountManager"))\r
- \r
+\r
def cleanup(self):\r
iNetwork.stopRestartConsole()\r
iNetwork.stopGetInterfacesConsole()\r
self.list.append((_("Change hostname"),"hostname", _("Change the hostname of your Dreambox."), okpng))\r
self["config"].setList(self.list)\r
\r
-\r
def exit(self):\r
self.close()\r
- \r
+\r
def keyOK(self, returnValue = None):\r
if returnValue == None:\r
returnValue = self["config"].getCurrent()[1]\r
self.userEdit()\r
elif returnValue is "hostname":\r
self.hostEdit()\r
+\r
def addMount(self):\r
self.session.open(AutoMountEdit, self.skin_path)\r
\r
def viewMounts(self):\r
self.session.open(AutoMountView, self.skin_path)\r
- \r
+\r
def userEdit(self):\r
self.session.open(UserManager, self.skin_path)\r
\r
self.hostname = fp.read()\r
fp.close()\r
self.session.openWithCallback(self.hostnameCallback, VirtualKeyBoard, title = (_("Enter new hostname for your Dreambox")), text = self.hostname)\r
- \r
+\r
def hostnameCallback(self, callback = None):\r
if callback is not None and len(callback):\r
fp = open('/etc/hostname', 'w+')\r
def restartLan(self):\r
iNetwork.restartNetwork(self.restartLanDataAvail)\r
self.restartLanRef = self.session.openWithCallback(self.restartfinishedCB, MessageBox, _("Please wait while your network is restarting..."), type = MessageBox.TYPE_INFO, enable_input = False)\r
- \r
+\r
def restartLanDataAvail(self, data):\r
if data is True:\r
iNetwork.getInterfaces(self.getInterfacesDataAvail)\r
from Screens.Screen import Screen\r
from Screens.MessageBox import MessageBox\r
from Components.Label import Label\r
-from Components.Pixmap import Pixmap\r
from Components.ActionMap import ActionMap\r
-from Components.MenuList import MenuList\r
-from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest\r
from Components.Network import iNetwork\r
-from Components.Console import Console\r
from Components.Sources.List import List\r
-from enigma import eListboxPythonMultiContent, gFont, eTimer\r
from Tools.LoadPixmap import LoadPixmap\r
from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE\r
-from os import system, popen, path as os_path, listdir\r
from AutoMount import iAutoMount, AutoMount\r
from MountEdit import AutoMountEdit\r
\r
-\r
class AutoMountView(Screen):\r
skin = """\r
<screen name="AutoMountView" position="90,140" size="560,350" title="MountView">\r
<widget name="legend1" position="0,0" zPosition="1" size="130,40" font="Regular;18" halign="center" valign="center" />\r
<widget name="legend2" position="130,0" zPosition="1" size="310,40" font="Regular;18" halign="center" valign="center" />\r
<widget name="legend3" position="410,0" zPosition="1" size="100,40" font="Regular;18" halign="center" valign="center" />\r
- <ePixmap pixmap="skin_default/div-h.png" position="0,40" zPosition="2" size="560,2" /> \r
+ <ePixmap pixmap="skin_default/div-h.png" position="0,40" zPosition="2" size="560,2" />\r
<widget source="config" render="Listbox" position="5,50" size="555,200" scrollbarMode="showOnDemand">\r
<convert type="TemplatedMultiContent">\r
{"template": [\r
<widget name="deletetext" position="50,305" size="350,21" zPosition="10" font="Regular;21" transparent="1" />\r
<ePixmap pixmap="skin_default/bottombar.png" position="10,250" size="540,120" zPosition="1" transparent="1" alphatest="on" />\r
</screen>"""\r
- \r
+\r
def __init__(self, session, plugin_path):\r
self.skin_path = plugin_path\r
self.session = session\r
self["introduction"] = Label(_("Press OK to edit the settings."))\r
self["ButtonRedtext"] = Label(_("Close"))\r
self["deletetext"] = Label(_("Delete selected mount"))\r
- \r
+\r
self.list = []\r
self["config"] = List(self.list)\r
self.showMountsList()\r
if cur:\r
returnValue = cur[1]\r
self.session.openWithCallback(self.MountEditClosed, AutoMountEdit, self.skin_path, iAutoMount.automounts[returnValue])\r
- \r
+\r
def MountEditClosed(self, returnValue = None):\r
if returnValue == None:\r
self.showMountsList()\r
- \r
\r
def delete(self, returnValue = None):\r
cur = self["config"].getCurrent()\r
def applyConfigfinishedCB(self,data):\r
if data is True:\r
self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network mount has been removed."), type = MessageBox.TYPE_INFO, timeout = 10)\r
- \r
- \r
+\r
def ConfigfinishedCB(self,data):\r
if data is not None:\r
if data is True:\r
self.showMountsList()\r
- \r
\r
from enigma import eTimer, getDesktop
from Screens.Screen import Screen
from Screens.MessageBox import MessageBox
-from Components.config import config, ConfigText, ConfigPassword, getConfigListEntry, ConfigNothing, ConfigSubsection, ConfigSubList, ConfigSubDict, ConfigIP
-from Components.ConfigList import ConfigListScreen
from Components.Label import Label
-from Components.Pixmap import Pixmap
from Components.ActionMap import ActionMap, NumberActionMap
from Components.Sources.List import List
from Components.Network import iNetwork
from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE
from Tools.LoadPixmap import LoadPixmap
from cPickle import dump, load
-from os import path as os_path, unlink, stat, mkdir,remove
+from os import path as os_path, stat, mkdir, remove
from time import time
from stat import ST_MTIME
try:
mkdir( os_path.dirname(cache_file) )
except OSError:
- print os_path.dirname(cache_file), 'is a file'
+ print os_path.dirname(cache_file), 'is a file'
fd = open(cache_file, 'w')
dump(cache_data, fd, -1)
fd.close()
<ePixmap pixmap="skin_default/buttons/button_yellow.png" position="30,420" zPosition="10" size="15,16" transparent="1" alphatest="on" />
<widget name="rescantext" position="50,420" size="300,21" zPosition="10" font="Regular;21" transparent="1" />
</screen>"""
-
+
def __init__(self, session, iface,plugin_path):
Screen.__init__(self, session)
self.skin_path = plugin_path
self.device = None
self.mounts = None
self.expanded = []
- self.cache_ttl = 604800 #Seconds cache is considered valid, 7 Days should be ok
- self.cache_file = '/etc/enigma2/networkbrowser.cache' #Path to cache directory
-
+ self.cache_ttl = 604800 #Seconds cache is considered valid, 7 Days should be ok
+ self.cache_file = '/etc/enigma2/networkbrowser.cache' #Path to cache directory
+
self["closetext"] = Label(_("Close"))
self["mounttext"] = Label(_("Mounts management"))
self["rescantext"] = Label(_("Rescan network"))
self["infotext"] = Label(_("Press OK to mount!"))
self["searchtext"] = Label(_("Scan IP"))
-
+
self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"],
{
"ok": self.go,
"yellow": self.keyYellow,
"blue": self.keyBlue,
})
-
+
self.list = []
self.statuslist = []
self.listindex = 0
self["list"] = List(self.list)
self["list"].onSelectionChanged.append(self.selectionChanged)
-
+
self.onLayoutFinish.append(self.startRun)
self.onShown.append(self.setWindowTitle)
- self.onClose.append(self.cleanup)
+ self.onClose.append(self.cleanup)
self.Timer = eTimer()
- self.Timer.callback.append(self.TimerFire)
+ self.Timer.callback.append(self.TimerFire)
def cleanup(self):
del self.Timer
if self.cache_ttl > 0 and self.vc != 0:
self.process_NetworkIPs()
else:
- self.Timer.start(3000)
-
+ self.Timer.start(3000)
+
def TimerFire(self):
self.Timer.stop()
self.process_NetworkIPs()
-
+
def setWindowTitle(self):
self.setTitle(_("Browse network neighbourhood"))
-
+
def keyGreen(self):
self.session.open(AutoMountManager, None, self.skin_path)
def keyYellow(self):
if (os_path.exists(self.cache_file) == True):
remove(self.cache_file)
- self.startRun()
+ self.startRun()
def keyBlue(self):
self.session.openWithCallback(self.scanIPclosed,ScanIP)
self.statuslist = []
if status == 'update':
statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/update.png"))
- self.statuslist.append(( ['info'], statuspng, _("Searching your network. Please wait..."), None, None, None, None ))
- self['list'].setList(self.statuslist)
+ self.statuslist.append(( ['info'], statuspng, _("Searching your network. Please wait..."), None, None, None, None ))
+ self['list'].setList(self.statuslist)
elif status == 'error':
statuspng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/error.png"))
- self.statuslist.append(( ['info'], statuspng, _("No network devices found!"), None, None, None, None ))
- self['list'].setList(self.statuslist)
-
+ self.statuslist.append(( ['info'], statuspng, _("No network devices found!"), None, None, None, None ))
+ self['list'].setList(self.statuslist)
+
def process_NetworkIPs(self):
self.inv_cache = 0
self.vc = valid_cache(self.cache_file, self.cache_ttl)
self.updateHostsList()
else:
self.setStatus('error')
-
+
def getNetworkIPs(self):
nwlist = []
sharelist = []
nwlist.append(netscan.netzInfo(strIP))
tmplist = nwlist[0]
return tmplist
-
+
def getNetworkShares(self,hostip,hostname,devicetype):
sharelist = []
self.sharecache_file = None
else:
username = "username"
password = "password"
-
+
if devicetype == 'unix':
smblist=netscan.smbShare(hostip,hostname,username,password)
for x in smblist:
for x in smblist:
if len(x) == 6:
if x[3] != 'IPC$':
- sharelist.append(x)
+ sharelist.append(x)
return sharelist
def updateHostsList(self):
name = hostentry[2] + " ( " +hostentry[1].strip() + " )"
print hostentry
expandableIcon = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/host.png"))
- self.list.append(( hostentry, expandableIcon, name, None, None, None, None ))
+ self.list.append(( hostentry, expandableIcon, name, None, None, None, None ))
self["list"].setList(self.list)
self["list"].setIndex(self.listindex)
hostentry = self.network[x][0][1]
name = hostentry[2] + " ( " +hostentry[1].strip() + " )"
expandedIcon = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/host.png"))
- self.list.append(( hostentry, expandedIcon, name, None, None, None, None ))
+ self.list.append(( hostentry, expandedIcon, name, None, None, None, None ))
for share in networkshares:
self.list.append(self.BuildNetworkShareEntry(share))
else: # HOSTLIST - VIEW
hostentry = self.network[x][0][1]
name = hostentry[2] + " ( " +hostentry[1].strip() + " )"
expandableIcon = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/host.png"))
- self.list.append(( hostentry, expandableIcon, name, None, None, None, None ))
+ self.list.append(( hostentry, expandableIcon, name, None, None, None, None ))
self["list"].setList(self.list)
self["list"].setIndex(self.listindex)
isMountedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/ok.png"))
else:
isMountedpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_PLUGINS, "SystemPlugins/NetworkBrowser/icons/cancel.png"))
-
+
return((share, verticallineIcon, None, sharedir, sharedescription, newpng, isMountedpng))
def selectionChanged(self):
self.listindex = self["list"].getIndex()
print len(current)
if current:
- if current[0][0] in ( "nfsShare", "smbShare"):
+ if current[0][0] in ("nfsShare", "smbShare"):
self["infotext"].show()
else:
self["infotext"].hide()
-
+
def go(self):
sel = self["list"].getCurrent()
if sel is None:
def UserDialogClosed(self, *ret):
if ret is not None and len(ret):
self.go()
-
+
def openMountEdit(self, selection):
if selection is not None and len(selection):
mounts = iAutoMount.getMountsList()
if selection[0] == 'nfsShare': # share entry selected
#Initialize blank mount enty
- data = { 'isMounted': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype' : False, 'options' : False }
+ data = { 'isMounted': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype' : False, 'options' : False }
# add data
data['mounttype'] = 'nfs'
data['active'] = True
self.session.openWithCallback(self.MountEditClosed,AutoMountEdit, self.skin_path, data)
if selection[0] == 'smbShare': # share entry selected
#Initialize blank mount enty
- data = { 'isMounted': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype' : False, 'options' : False }
+ data = { 'isMounted': False, 'active': False, 'ip': False, 'sharename': False, 'sharedir': False, 'username': False, 'password': False, 'mounttype' : False, 'options' : False }
# add data
data['mounttype'] = 'cifs'
data['active'] = True
<ePixmap pixmap="skin_default/buttons/green.png" position="160,40" zPosition="2" size="140,40" transparent="1" alphatest="on" />
<widget name="edittext" position="170,50" size="300,21" zPosition="10" font="Regular;21" transparent="1" />
</screen>"""
-
+
def __init__(self, session):
Screen.__init__(self, session)
self.session = session
self["closetext"] = Label(_("Cancel"))
self["edittext"] = Label(_("OK"))
-
+
if (y>=720):
self["text"] = Input(text, maxSize=False, type=Input.TEXT)
else:
self["text"] = Input(text, maxSize=False, visible_width = 55, type=Input.TEXT)
-
- self["actions"] = NumberActionMap(["WizardActions", "InputActions", "TextEntryActions", "KeyboardInputActions","ShortcutActions"],
+
+ self["actions"] = NumberActionMap(["WizardActions", "InputActions", "TextEntryActions", "KeyboardInputActions","ShortcutActions"],
{
"ok": self.go,
"back": self.exit,
}, -1)
self.onLayoutFinish.append(self.layoutFinished)
-
+
def exit(self):
self.close(None)
def setWindowTitle(self):
self.setTitle(_("Enter IP to scan..."))
-
+
def go(self):
text = self["text"].getText()
if text:
self.close(text)
-
+
def keyLeft(self):
self["text"].left()
-
+
def keyRight(self):
self["text"].right()
-
+
def keyHome(self):
self["text"].home()
-
+
def keyEnd(self):
self["text"].end()
-
+
def keyDeleteForward(self):
self["text"].delete()
-
+
def keyDeleteBackward(self):
self["text"].deleteBackward()
-
+
def keyNumberGlobal(self, number):
print "pressed", number
self["text"].number(number)
+
from Screens.MessageBox import MessageBox
from Screens.VirtualKeyBoard import VirtualKeyBoard
from Components.ActionMap import ActionMap
-from Components.Button import Button
-from Components.config import config, ConfigText, ConfigPassword, NoSave, getConfigListEntry, ConfigNothing, ConfigSubsection, ConfigSubList, ConfigSubDict
+from Components.config import ConfigText, ConfigPassword, NoSave, getConfigListEntry
from Components.ConfigList import ConfigListScreen
-from Components.Label import Label,MultiColorLabel
-from Components.Pixmap import Pixmap,MultiPixmap
+from Components.Label import Label
+from Components.Pixmap import Pixmap
from Components.ActionMap import ActionMap, NumberActionMap
-from enigma import eTimer, ePoint, eSize, RT_HALIGN_LEFT, eListboxPythonMultiContent, gFont
+from enigma import ePoint
from cPickle import dump, load
-from os import path as os_path, system as os_system, unlink, stat, mkdir
+from os import path as os_path, unlink, stat, mkdir
from time import time
from stat import ST_MTIME
try:
mkdir( os_path.dirname(cache_file) )
except OSError:
- print os_path.dirname(cache_file), 'is a file'
+ print os_path.dirname(cache_file), 'is a file'
fd = open(cache_file, 'w')
dump(cache_data, fd, -1)
fd.close()
<widget name="ButtonRedtext" position="410,345" size="140,21" zPosition="10" font="Regular;21" transparent="1" />
<widget name="ButtonRed" pixmap="skin_default/buttons/button_red.png" position="390,345" zPosition="10" size="15,16" transparent="1" alphatest="on" />
<widget name="VKeyIcon" pixmap="skin_default/vkey_icon.png" position="35,310" zPosition="10" size="60,48" transparent="1" alphatest="on" />
- <widget name="HelpWindow" pixmap="skin_default/vkey_icon.png" position="175,300" zPosition="1" size="1,1" transparent="1" alphatest="on" />
+ <widget name="HelpWindow" pixmap="skin_default/vkey_icon.png" position="175,300" zPosition="1" size="1,1" transparent="1" alphatest="on" />
<ePixmap pixmap="skin_default/bottombar.png" position="10,290" size="540,120" zPosition="1" transparent="1" alphatest="on" />
</screen>"""
self.session = session
Screen.__init__(self, self.session)
self.hostinfo = hostinfo
- self.cache_ttl = 86400 #600 is default, 0 disables, Seconds cache is considered valid
+ self.cache_ttl = 86400 #600 is default, 0 disables, Seconds cache is considered valid
self.cache_file = '/etc/enigma2/' + self.hostinfo + '.cache' #Path to cache directory
self.createConfig()
-
+
self["shortcuts"] = ActionMap(["ShortcutActions","WizardActions"],
{
"red": self.close,
def layoutFinished(self):
print self["config"].getCurrent()
- self.setTitle(_("Enter user and password for host: ")+ self.hostinfo)
+ self.setTitle(_("Enter user and password for host: ")+ self.hostinfo)
self["ButtonGreen"].show()
self["VKeyIcon"].show()
self["VirtualKB"].setEnabled(True)
self.passwordEntry = None
self.username = None
self.password = None
-
+
if os_path.exists(self.cache_file):
print 'Loading user cache from ',self.cache_file
try:
self.username = NoSave(ConfigText(default = username, visible_width = 50, fixed_size = False))
self.password = NoSave(ConfigPassword(default = password, visible_width = 50, fixed_size = False))
-
+
def createSetup(self):
self.list = []
self.usernameEntry = getConfigListEntry(_("Username"), self.username)
self["config"].l.setList(self.list)
self["config"].onSelectionChanged.append(self.selectionChanged)
-
def KeyGreen(self):
if self["config"].getCurrent() == self.usernameEntry:
self.session.openWithCallback(lambda x : self.VirtualKeyBoardCallback(x, 'username'), VirtualKeyBoard, title = (_("Enter username:")), text = self.username.value)
if self["config"].getCurrent() == self.passwordEntry:
self.session.openWithCallback(lambda x : self.VirtualKeyBoardCallback(x, 'password'), VirtualKeyBoard, title = (_("Enter password:")), text = self.password.value)
-
def VirtualKeyBoardCallback(self, callback = None, entry = None):
if callback is not None and len(callback) and entry is not None and len(entry):
if entry == 'username':
def ok(self):
current = self["config"].getCurrent()
- self.hostdata = { 'username': self.username.value, 'password': self.password.value }
+ self.hostdata = { 'username': self.username.value, 'password': self.password.value }
write_cache(self.cache_file, self.hostdata)
self.close(True)
-
+
from Tools.LoadPixmap import LoadPixmap\r
from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE\r
from UserDialog import UserDialog\r
-from os import path as os_path, system as os_system, unlink, stat, mkdir, listdir\r
+from os import unlink, listdir\r
\r
class UserManager(Screen):\r
skin = """\r
self["ButtonRedtext"] = Label(_("Close"))\r
self["introduction"] = Label(_("Press OK to edit selected settings."))\r
self["deletetext"] = Label(_("Delete"))\r
- \r
+\r
self.list = []\r
self["config"] = List(self.list)\r
self.updateList()\r
\r
def exit(self):\r
self.close()\r
- \r
+\r
def keyOK(self, returnValue = None):\r
cur = self["config"].getCurrent()\r
if cur:\r
if os_path.exists(cachefile):\r
unlink(cachefile)\r
self.updateList()\r
+\r
print "[NetworkBrowser] fallback to default translation for", txt\r
t = gettext.gettext(txt)\r
return t\r
- \r
+\r
localeInit()\r
-language.addCallback(localeInit)
\ No newline at end of file
+language.addCallback(localeInit)\r
from NetworkBrowser import NetworkBrowser\r
from Components.Network import iNetwork\r
from MountManager import AutoMountManager\r
-from os import path\r
\r
plugin_path = ""\r
\r