コード例 #1
0
ファイル: About.py プロジェクト: Haehnchen/enigma2-plugins
	def command(self):
		ConvertIP = lambda l: "%s.%s.%s.%s" % tuple(l) if len(l) == 4 else "0.0.0.0"
		ifaces = iNetworkInfo.getConfiguredInterfaces()
		for key in ifaces.iterkeys():
			iface = ifaces[key]
			print "[WebComponents.About] iface: %s" % iface
			l = (
				iface.ethernet.mac,
				iface.ipv4.method,
				iface.ipv4.address,
				iface.ipv4.netmask,
				iface.ipv4.gateway,
			)
			break
		else:
			print "[WebComponents.About] no network iface configured!"
			l = (
				"N/A",
				"N/A",
				"N/A",
				"N/A",
				"N/A",
			)

		return (l,)
コード例 #2
0
	def isAuthenticated(self, request):
		self._assignLocalNetworks(iNetworkInfo.getConfiguredInterfaces())
		if request.transport:
			host = IPNetwork(request.transport.getPeer().host)
			#If streamauth is disabled allow all acces from localhost
			if not config.plugins.Webinterface.streamauth.value:
				if self._isLocalHost(host.ip):
					Log.i("Streaming auth is disabled - Bypassing Authcheck because host '%s' is local!" %host)
					return True
			if not config.plugins.Webinterface.localauth.value:
				if self._isLocalClient(host.ip):
					Log.i("Local auth is disabled - Bypassing Authcheck because host '%s' is local!" %host)
					return True

		# get the Session from the Request
		http_session = request.getSession().sessionNamespaces

		# if the auth-information has not yet been stored to the http_session
		if not http_session.has_key('authenticated'):
			if request.getUser() and request.getPassword():
				http_session['authenticated'] = check_passwd(request.getUser(), request.getPassword())
			else:
				http_session['authenticated'] = False

		#if the auth-information already is in the http_session
		else:
			if http_session['authenticated'] is False:
				http_session['authenticated'] = check_passwd(request.getUser(), request.getPassword() )

		#return the current authentication status
		return http_session['authenticated']
コード例 #3
0
ファイル: plugin.py プロジェクト: OpenDMM/enigma2-plugins
	def isAuthenticated(self, request):
		self._assignLocalNetworks(iNetworkInfo.getConfiguredInterfaces())
		if request.transport:
			host = IPNetwork(request.transport.getPeer().host)
			#If streamauth is disabled allow all acces from localhost
			if not config.plugins.Webinterface.streamauth.value:
				if self._isLocalHost(host.ip):
					Log.i("Streaming auth is disabled - Bypassing Authcheck because host '%s' is local!" %host)
					return True
			if not config.plugins.Webinterface.localauth.value:
				if self._isLocalClient(host.ip):
					Log.i("Local auth is disabled - Bypassing Authcheck because host '%s' is local!" %host)
					return True

		# get the Session from the Request
		http_session = request.getSession().sessionNamespaces

		# if the auth-information has not yet been stored to the http_session
		if not http_session.has_key('authenticated'):
			if request.getUser() and request.getPassword():
				http_session['authenticated'] = check_passwd(request.getUser(), request.getPassword())
			else:
				http_session['authenticated'] = False

		#if the auth-information already is in the http_session
		else:
			if http_session['authenticated'] is False:
				http_session['authenticated'] = check_passwd(request.getUser(), request.getPassword() )

		#return the current authentication status
		return http_session['authenticated']
コード例 #4
0
ファイル: About.py プロジェクト: xmasmc/enigma2-plugins
    def command(self):
        ConvertIP = lambda l: "%s.%s.%s.%s" % tuple(l) if len(
            l) == 4 else "0.0.0.0"
        ifaces = iNetworkInfo.getConfiguredInterfaces()
        for key in ifaces.iterkeys():
            iface = ifaces[key]
            print "[WebComponents.About] iface: %s" % iface
            l = (
                iface.ethernet.mac,
                iface.ipv4.method,
                iface.ipv4.address,
                iface.ipv4.netmask,
                iface.ipv4.gateway,
            )
            break
        else:
            print "[WebComponents.About] no network iface configured!"
            l = (
                "N/A",
                "N/A",
                "N/A",
                "N/A",
                "N/A",
            )

        return (l, )
コード例 #5
0
    def _setInfoText(self):
        if not self._streamServerControl.isConnected():
            self._info.setText(_("ERROR: Streaming Server not available!"))
            return

        detailtext = _("Local client(s):\n    %s") % (self._clientCount)
        self._details.setText(detailtext)

        localstreams = []
        if config.streamserver.rtsp.enabled.value or config.streamserver.hls.enabled.value:
            ifaces = iNetworkInfo.getConfiguredInterfaces()
            for iface in ifaces.itervalues():
                ip = iface.getIpv4()
                if not ip:
                    ip = iface.getIpv6()
                if ip:
                    if config.streamserver.rtsp.enabled.value:
                        localstreams.append(
                            "rtsp://%s:%s/%s" %
                            (ip.getAddress(),
                             config.streamserver.rtsp.port.value,
                             config.streamserver.rtsp.path.value))
                    if config.streamserver.hls.enabled.value:
                        localstreams.append(
                            "http://%s:%s/dream.m3u8" %
                            (ip.getAddress(),
                             config.streamserver.hls.port.value))
                    break

        infotext = ""
        if not localstreams:
            infotext = _("no active streams...")
        else:
            infotext = "\n".join(localstreams)
        self._info.setText(infotext)
コード例 #6
0
 def getInterface(self):
     ifaces = iNetworkInfo.getConfiguredInterfaces()
     Log.i(ifaces)
     for key in ifaces.iterkeys():
         iface = ifaces[key]
         if iface.ethernet.interface == self.iface:
             return self.__getInterfaceAttribs(iface)
     return ["N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A"]
コード例 #7
0
ファイル: Network.py プロジェクト: wedebe/enigma2-plugins-2
    def getList(self):
        lst = []
        ifaces = iNetworkInfo.getConfiguredInterfaces()
        Log.d(ifaces)
        for key in ifaces.iterkeys():
            iface = ifaces[key]
            lst.append(self.__getInterfaceAttribs(iface))

        return lst
コード例 #8
0
    def getList(self):
        lst = []
        ifaces = iNetworkInfo.getConfiguredInterfaces()
        Log.i(ifaces)
        for key in ifaces.iterkeys():
            iface = ifaces[key]
            lst.append(self.__getInterfaceAttribs(iface))

        return lst
コード例 #9
0
	def getNetworkIPs(self):
		nwlist = []
		sharelist = []
		self.IP = iNetworkInfo.getConfiguredInterfaces()[self.iface].ipv4.address.split(".")
		if len(self.IP):
			strIP = "%s.0/24" %( ".".join(self.IP[0:3]) )
			Log.i(strIP)
			nwlist.append(netscan.netInfo(strIP))
		tmplist = nwlist[0]
		return tmplist
コード例 #10
0
ファイル: Network.py プロジェクト: wedebe/enigma2-plugins-2
 def getInterface(self):
     ifaces = iNetworkInfo.getConfiguredInterfaces()
     Log.d(ifaces)
     for key in ifaces.iterkeys():
         iface = ifaces[key]
         if iface.ethernet.interface == self.iface:
             return self.__getInterfaceAttribs(iface)
     return [
         "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A",
         "N/A"
     ]
コード例 #11
0
ファイル: imports.py プロジェクト: n3wb13/OpenNfrGui-5.0-1
def getMac():
	try:
		from Components.Network import iNetwork
		BoxID = iNetwork.getAdapterAttribute("eth0", "mac")
	except:
		try:
			from Components.Network import iNetworkInfo
			ifaces = iNetworkInfo.getConfiguredInterfaces()
			iface = ifaces["eth0"]
			BoxID = iface.ethernet.mac
		except:
			BoxID = "N/A"

	return BoxID
コード例 #12
0
    def __init__(self, session, iface, plugin_path):
        Screen.__init__(self, session)
        self.skin_path = plugin_path
        self.session = session
        self.iface = iface or 'eth0'
        for service in eNetworkManager.getInstance().getServices():
            key = self.getServiceIF(service)
            if key:
                self.iface = key
                break
        self.networklist = []
        self.expanded = []
        self.cache_ttl = 604800  #Seconds cache is considered valid, 7 Days should be ok
        self.cache_file = eEnv.resolve(
            "${sysconfdir}/enigma2/networkbrowser.cache"
        )  #Path to cache directory
        self._nrthreads = 0
        self._netbios = NetBIOS(broadcast=False)
        self._ipv4 = iNetworkInfo.getConfiguredInterfaces()[self.iface].ipv4
        self._myhostname = self._lookupHostname(self._ipv4.address, local=True)

        self["key_red"] = StaticText(_("Close"))
        self["key_green"] = StaticText(_("Mounts"))
        self["key_yellow"] = StaticText(_("Rescan"))
        self["key_blue"] = StaticText(_("Expert"))
        self["infotext"] = StaticText(_("Press OK to mount!"))

        self["shortcuts"] = ActionMap(
            ["ShortcutActions", "WizardActions"], {
                "ok": self.go,
                "back": self.close,
                "red": self.close,
                "green": self.keyGreen,
                "yellow": self.keyYellow,
                "blue": self.keyBlue,
            })

        self.list = []
        self.statuslist = []
        self.listindex = 0
        self["list"] = List(self.list)
        self["list"].onSelectionChanged.append(self._onSelectionChanged)

        self.onLayoutFinish.append(self.startRun)
        self.onShown.append(self.setWindowTitle)
        self.onClose.append(self.cleanup)
        self.Timer = eTimer()
        self.Timer_conn = self.Timer.timeout.connect(self.TimerFire)
コード例 #13
0
	def __init__(self, session, iface,plugin_path):
		Screen.__init__(self, session)
		self.skin_path = plugin_path
		self.session = session
		self.iface = iface or 'eth0'
		for service in eNetworkManager.getInstance().getServices():
			key = self.getServiceIF(service)
			if key:
				self.iface = key
				break
		self.networklist = []
		self.expanded = []
		self.cache_ttl = 604800 #Seconds cache is considered valid, 7 Days should be ok
		self.cache_file = eEnv.resolve("${sysconfdir}/enigma2/networkbrowser.cache") #Path to cache directory
		self._nrthreads = 0
		self._netbios = NetBIOS(broadcast=False)
		self._ipv4 = iNetworkInfo.getConfiguredInterfaces()[self.iface].ipv4
		self._myhostname = self._lookupHostname(self._ipv4.address, local=True)

		self["key_red"] = StaticText(_("Close"))
		self["key_green"] = StaticText(_("Mounts"))
		self["key_yellow"] = StaticText(_("Rescan"))
		self["key_blue"] = StaticText(_("Expert"))
		self["infotext"] = StaticText(_("Press OK to mount!"))
		
		self["shortcuts"] = ActionMap(["ShortcutActions", "WizardActions"],
		{
			"ok": self.go,
			"back": self.close,
			"red": self.close,
			"green": self.keyGreen,
			"yellow": self.keyYellow,
			"blue": self.keyBlue,
		})

		self.list = []
		self.statuslist = []
		self.listindex = 0
		self["list"] = List(self.list)
		self["list"].onSelectionChanged.append(self._onSelectionChanged)

		self.onLayoutFinish.append(self.startRun)
		self.onShown.append(self.setWindowTitle)
		self.onClose.append(self.cleanup)
		self.Timer = eTimer()
		self.Timer_conn = self.Timer.timeout.connect(self.TimerFire)
コード例 #14
0
	def process_NetworkIPs(self):
		self.inv_cache = 0
		self.vc = valid_cache(self.cache_file, self.cache_ttl)
		if self.cache_ttl > 0 and self.vc != 0:
			Log.i('Loading network cache from %s' %(self.cache_file))
			try:
				self.networklist = load_cache(self.cache_file)
				if len(self.networklist) > 0:
					self.updateHostsList()
				else:
					self.setStatus('error')
			except:
				self.inv_cache = 1
		if self.cache_ttl == 0 or self.inv_cache == 1 or self.vc == 0:
			Log.i('Getting fresh network list')
			self._ip = iNetworkInfo.getConfiguredInterfaces()[self.iface].ipv4.address.split(".")
			reactor.callInThread(self.getNetworkIPs)
コード例 #15
0
ファイル: StreamServerConfig.py プロジェクト: OpenDMM/enigma2
	def _setInfoText(self):
		detailtext =_("Local client(s):\n    %s") %(self._clientCount)
		self._details.setText(detailtext)

		localstreams = []
		if self._streamServerControl.config.streamserver.rtsp.enabled.value or self._streamServerControl.config.streamserver.hls.enabled.value:
			ifaces = iNetworkInfo.getConfiguredInterfaces()
			for iface in ifaces.itervalues():
				ip = iface.getIpv4()
				if not ip:
					ip = iface.getIpv6()
				if ip:
					if self._streamServerControl.config.streamserver.rtsp.enabled.value:
						localstreams.append("rtsp://%s:%s/%s" %(ip.getAddress(), self._streamServerControl.config.streamserver.rtsp.port.value, self._streamServerControl.config.streamserver.rtsp.path.value))
					if self._streamServerControl.config.streamserver.hls.enabled.value:
						localstreams.append("http://%s:%s/%s.m3u8" %(ip.getAddress(), self._streamServerControl.config.streamserver.hls.port.value, self._streamServerControl.config.streamserver.hls.path.value))
					break

		infotext = ""
		if not localstreams:
			infotext = _("no active streams...")
		else:
			infotext = "\n".join(localstreams)
		self._info.setText(infotext)
コード例 #16
0
	def _setInfoText(self):
		detailtext =_("Local client(s):\n    %s") %(self._clientCount)
		self._details.setText(detailtext)

		localstreams = []
		if self._streamServerControl.config.streamserver.rtsp.enabled.value or self._streamServerControl.config.streamserver.hls.enabled.value:
			ifaces = iNetworkInfo.getConfiguredInterfaces()
			for iface in six.itervalues(ifaces):
				ip = iface.getIpv4()
				if not ip:
					ip = iface.getIpv6()
				if ip:
					if self._streamServerControl.config.streamserver.rtsp.enabled.value:
						localstreams.append("rtsp://%s:%s/%s" %(ip.getAddress(), self._streamServerControl.config.streamserver.rtsp.port.value, self._streamServerControl.config.streamserver.rtsp.path.value))
					if self._streamServerControl.config.streamserver.hls.enabled.value:
						localstreams.append("http://%s:%s/%s.m3u8" %(ip.getAddress(), self._streamServerControl.config.streamserver.hls.port.value, self._streamServerControl.config.streamserver.hls.path.value))
					break

		infotext = ""
		if not localstreams:
			infotext = _("no active streams...")
		else:
			infotext = "\n".join(localstreams)
		self._info.setText(infotext)
コード例 #17
0
ファイル: plugin.py プロジェクト: Haehnchen/enigma2-plugins
	def updateStatus(self):
		print "[TVCharts] Status Update ..."
		self.DBStatusTimer.stop()

		if not config.plugins.tvcharts.enabled.value or Screens.Standby.inStandby:
			return

		# Get Channelname
		sref = self.session.nav.getCurrentlyPlayingServiceReference()
		if sref is not None:
			ref = eServiceReference(sref.toString())
			ref.setName("")
			serviceHandler = eServiceCenter.getInstance()
			info = serviceHandler.info(ref)
			channel_name = info and info.getName(ref).replace('\xc2\x86', '').replace('\xc2\x87', '').decode("utf-8", "ignore").encode("utf-8") or ""
			self.serviceref = ref.toString()
		else:
			channel_name = ""
			self.serviceref = ""

		# Get Event Info
		service = self.session.nav.getCurrentService()
		info = service and service.info()
		event = info and info.getEvent(0)
		event_name = event and event.getEventName() or ""
		event_description = ""
		event_begin = 0

		if event is not None:
			curEvent = parseEvent(event)
			event_begin = int(curEvent[0])+(config.recording.margin_before.value*60)
			event_description = event.getExtendedDescription()

		# Get Box Info
		ifaces = iNetworkInfo.getConfiguredInterfaces()
		iface = None
		if len(ifaces) > 0:
			iface = ifaces.get(
					"eth0",
					ifaces.get(ifaces.keys()[0])
				)
		if not iface:
			return
		self.BoxID = iface.ethernet.mac
		self.DeviceName = HardwareInfo().get_device_name()
		self.EnigmaVersion = about.getEnigmaVersionString()
		self.ImageVersion = about.getVersionString()

		# Get TimerList
		self.timerlist = ""
		if config.plugins.tvcharts.submittimers.value and self.LastTimerlistUpdate <= (time()-1800):
			self.LastTimerlistUpdate = time()
			try:
				for timer in self.recordtimer.timer_list:
					if timer.disabled == 0 and timer.justplay == 0:
						self.timerlist += "%s|%s|%s|%s|%s|%s|%s\n" % (timer.eit,str(int(timer.begin)+(config.recording.margin_before.value*60)), str(int(timer.end)-(config.recording.margin_after.value*60)), str(timer.service_ref), timer.name, timer.service_ref.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', '').decode("utf-8", "ignore").encode("utf-8"), timer.repeated)
			except Exception:
				print "[TVCharts] Error loading timers!"

		# Get Pluginlist
		if config.plugins.tvcharts.submitplugins.value and self.pluginlist == "":
			try:
				os_system("opkg list_installed | grep enigma2-plugin- > /tmp/plugins.txt")
				for plugin in open('/tmp/plugins.txt', 'r'):
					self.pluginlist += plugin[0:plugin.find(' - ')]+"\n"
				os_system("rm -f /tmp/plugins.txt")
			except Exception:
				print "[TVCharts] Error loading plugins!"
		
		# Status Update
		getPage(url='http://www.dreambox-plugins.de/feeds/TVCharts/status.php', agent="Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)", timeout=60, method='POST', headers={'Content-Type':'application/x-www-form-urlencoded'}, postdata=urlencode({'boxid' : self.BoxID, 'devicename' : self.DeviceName, 'imageversion' : self.ImageVersion, 'enigmaversion' : self.EnigmaVersion, 'lastchannel' : channel_name, 'lastevent' : event_name, 'eventdescr' : event_description, 'lastbegin' : event_begin, 'lastserviceref' : self.serviceref, 'timerlist' : self.timerlist, 'pluginlist' : self.pluginlist})).addErrback(self.updateError)

		# Restart Timer
		self.DBStatusTimer.start(900000, True)
コード例 #18
0
    def updateStatus(self):
        print "[TVCharts] Status Update ..."
        self.DBStatusTimer.stop()

        if not config.plugins.tvcharts.enabled.value or Screens.Standby.inStandby:
            return

        # Get Channelname
        sref = self.session.nav.getCurrentlyPlayingServiceReference()
        if sref is not None:
            ref = eServiceReference(sref.toString())
            ref.setName("")
            serviceHandler = eServiceCenter.getInstance()
            info = serviceHandler.info(ref)
            channel_name = info and info.getName(ref).replace(
                '\xc2\x86', '').replace('\xc2\x87', '').decode(
                    "utf-8", "ignore").encode("utf-8") or ""
            self.serviceref = ref.toString()
        else:
            channel_name = ""
            self.serviceref = ""

        # Get Event Info
        service = self.session.nav.getCurrentService()
        info = service and service.info()
        event = info and info.getEvent(0)
        event_name = event and event.getEventName() or ""
        event_description = ""
        event_begin = 0

        if event is not None:
            curEvent = parseEvent(event)
            event_begin = int(
                curEvent[0]) + (config.recording.margin_before.value * 60)
            event_description = event.getExtendedDescription()

        # Get Box Info
        ifaces = iNetworkInfo.getConfiguredInterfaces()
        iface = None
        if len(ifaces) > 0:
            iface = ifaces.get("eth0", ifaces.get(ifaces.keys()[0]))
        if not iface:
            return
        self.BoxID = iface.ethernet.mac
        self.DeviceName = HardwareInfo().get_device_name()
        self.EnigmaVersion = about.getEnigmaVersionString()
        self.ImageVersion = about.getVersionString()

        # Get TimerList
        self.timerlist = ""
        if config.plugins.tvcharts.submittimers.value and self.LastTimerlistUpdate <= (
                time() - 1800):
            self.LastTimerlistUpdate = time()
            try:
                for timer in self.recordtimer.timer_list:
                    if timer.disabled == 0 and timer.justplay == 0:
                        self.timerlist += "%s|%s|%s|%s|%s|%s|%s\n" % (
                            timer.eit,
                            str(
                                int(timer.begin) +
                                (config.recording.margin_before.value * 60)),
                            str(
                                int(timer.end) -
                                (config.recording.margin_after.value * 60)),
                            str(timer.service_ref), timer.name,
                            timer.service_ref.getServiceName().replace(
                                '\xc2\x86', '').replace('\xc2\x87', '').decode(
                                    "utf-8",
                                    "ignore").encode("utf-8"), timer.repeated)
            except Exception:
                print "[TVCharts] Error loading timers!"

        # Get Pluginlist
        if config.plugins.tvcharts.submitplugins.value and self.pluginlist == "":
            try:
                os_system(
                    "opkg list_installed | grep enigma2-plugin- > /tmp/plugins.txt"
                )
                for plugin in open('/tmp/plugins.txt', 'r'):
                    self.pluginlist += plugin[0:plugin.find(' - ')] + "\n"
                os_system("rm -f /tmp/plugins.txt")
            except Exception:
                print "[TVCharts] Error loading plugins!"

        # Status Update
        getPage(
            url='http://www.dreambox-plugins.de/feeds/TVCharts/status.php',
            agent="Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)",
            timeout=60,
            method='POST',
            headers={
                'Content-Type': 'application/x-www-form-urlencoded'
            },
            postdata=urlencode({
                'boxid': self.BoxID,
                'devicename': self.DeviceName,
                'imageversion': self.ImageVersion,
                'enigmaversion': self.EnigmaVersion,
                'lastchannel': channel_name,
                'lastevent': event_name,
                'eventdescr': event_description,
                'lastbegin': event_begin,
                'lastserviceref': self.serviceref,
                'timerlist': self.timerlist,
                'pluginlist': self.pluginlist
            })).addErrback(self.updateError)

        # Restart Timer
        self.DBStatusTimer.start(900000, True)
コード例 #19
0
import json

from urllib import urlencode
from math import ceil as math_ceil

from Tools.Log import Log

import time
from twisted.python.reflect import isinst

DEFAULT_SERVER = "stalker.server"
DEFAULT_SERVER_ROOT = "/stalker_portal"
DEFAULT_ENDPOINT = "/server/load.php"
MATRIX_ENDPOINT = "/server/matrix.php"

ifaces = iNetworkInfo.getConfiguredInterfaces()
mac = "00:00:00:00:00"
for iface in ifaces.itervalues():
    mac = iface.ethernet.mac
    if mac.startswith("00:09:34"):
        break
DEFAULT_MAC = mac
try:
    from defaults import *
except:
    pass

config.stalker_client = ConfigSubsection()
config.stalker_client.server = ConfigText(default=DEFAULT_SERVER,
                                          fixed_size=False)
config.stalker_client.server_root = ConfigText(default=DEFAULT_SERVER_ROOT,