You are not logged in.

Dear visitor, welcome to Dreamboard. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

silelis

Dreamer

  • "silelis" started this thread

Posts: 72

Location: Poland

Occupation: improve production processes

  • Send private message

1

Saturday, April 30th 2011, 3:55pm

How to properly use autostart

Hi,

I'm begginer at Python and Enigma 2 programming so I ask You about forbearance.

I try to write a sctipt which will detect (I hope) if DM is in standby mode.

At the moment I' m on autorun stage.

My code looks like below:

Quoted

class Lampki:
def __init__(self):
self.session = session
bb = pylibftdi.BitBangDevice()
while True:
""" wile I want to add if condition which will chcect isStandby
global wariable and will change bitbang mode. At the moment the
code it so chceck if autorun works properly"""
bb.port = 0b00000001
time.sleep(1)
bb.port = 0b00000010
time.sleep(1)

def autostart(reason, **kwargs):
# aa = Lampki ()
if reason == 0 and kwargs.has_key("session"):
session = kwargs["session"]
session.open(Lampki)

def main(session, **kwargs):
print "\n[MyMenu] start\n"
session.open(MyMenu)

###########################################################################

def Plugins(**kwargs):
list = [
PluginDescriptor(
name="Standby Energy Saver",
description="Manage Your Power Distribution Unit to save energy",
where = PluginDescriptor.WHERE_AUTOSTART,
fnc = autostart),
PluginDescriptor(
name="Standby Energy Saver",
where = PluginDescriptor.WHERE_PLUGINMENU,
icon="standysaver.png",
fnc=main)]
return list
The problem is that:

- if I un# line aa = Lampki () during rebooting enigma hungs up (simple BitBang device works porperly),
- if I # aa = .... line and un# f reason == 0 and kwargs.has_key("session"): and it' s body enigma reboots properly but device don't work.

Can someone help me. As I wrote I'm begginer.

P.S. The ideal state is if Lampki class behaves as daemon or detects standby switch event but I don't know how to do this (so maybe at the beginning infinitive while loop idea is anough).
"Reasonable people adapt themselves to the world.
Unreasonable people attempt to adapt the world to themselves.
All progress, therefore, depends on unreasonable people"

============
SubsDownloader

2

Saturday, April 30th 2011, 4:21pm

Is the shifting in your original .py-file also like here in the code-tags?

Thats the first problem, as in Python the shifting is part of the syntax. Compare to http://en.wikipedia.org/wiki/Python_(programming_language) and some Begginner's Guide for Python :)
so long
m0rphU

silelis

Dreamer

  • "silelis" started this thread

Posts: 72

Location: Poland

Occupation: improve production processes

  • Send private message

3

Saturday, April 30th 2011, 4:23pm

Yes they are (i know the python basis) the forum code don't allow to use shifting.
"Reasonable people adapt themselves to the world.
Unreasonable people attempt to adapt the world to themselves.
All progress, therefore, depends on unreasonable people"

============
SubsDownloader

4

Saturday, April 30th 2011, 4:54pm

Ok, then my basic knowledge won't help you ;)
so long
m0rphU

5

Saturday, April 30th 2011, 8:51pm

Autostart is to early, no session is available there, you have to attach to sessionstart. Check schwerkraft plugin repository and there the source for plugib KiddyTimer to see, how to do that.

To find out, wheather box goes to standby you simply add a notifier to a config variable:

93 config.misc.standbyCounter.addNotifier(self.enterStandby, initial_call = False)

As used in KTmain.py of Kiddytimer

Hth
Tode