[Butia-devel-list] [PATCH] Deshabilitar Energia - Final
Alan Jhonn Aguiar Schwyn
alanjas en hotmail.com
Vie Feb 22 14:59:45 UYST 2013
para qué las llamadas a power_manager(True) en cada comando de atrás, adelante, etc????
> From: nachoel01 en gmail.com
> To: butia-devel-l en fing.edu.uy
> Date: Fri, 22 Feb 2013 14:58:42 -0200
> CC: aaguire en fing.edu.uy
> Subject: [Butia-devel-list] [PATCH] Deshabilitar Energia - Final
>
> From: Ignacio Rodríguez <nachoel01 en gmail.com>
>
> ---
> TurtleArt/tautils.py | 46 ++++++++++++++++++++++++++++++++++++++++++++--
> plugins/butia/butia.py | 7 +++++++
> 2 files changed, 51 insertions(+), 2 deletions(-)
>
> diff --git a/TurtleArt/tautils.py b/TurtleArt/tautils.py
> index 3f9d1c4..66af526 100644
> --- a/TurtleArt/tautils.py
> +++ b/TurtleArt/tautils.py
> @@ -1,5 +1,6 @@
> #copyright (c) 2007-8, Playful Invention Company.
> #Copyright (c) 2008-13, Walter Bender
> +#Copyright (c) 2013, Ignacio Rodriguez
>
> #Permission is hereby granted, free of charge, to any person obtaining a copy
> #of this software and associated documentation files (the "Software"), to deal
> @@ -24,6 +25,8 @@ import cairo
> import pickle
> import subprocess
> import os
> +import gconf
> +import dbus
> import string
> from gettext import gettext as _
>
> @@ -48,6 +51,9 @@ from taconstants import (HIT_HIDE, HIT_SHOW, XO1, XO15, XO175, XO4, UNKNOWN,
> import logging
> _logger = logging.getLogger('turtleart-activity')
>
> +client = gconf.client_get_default()
> +ACTUAL_POWER = client.get_bool('/desktop/sugar/power/automatic')
> +
>
> def debug_output(message_string, running_sugar=False):
> ''' unified debugging output '''
> @@ -711,7 +717,7 @@ def get_hardware():
> if version == '1':
> return XO1
> elif version == '1.5':
> - return XO15
> + return XO15
> elif version == '1.75':
> return XO175
> elif version == '4':
> @@ -719,7 +725,7 @@ def get_hardware():
> else:
> # Some systems (e.g. ARM) don't have dmi info
> if os.path.exists('/sys/devices/platform/lis3lv02d/position'):
> - return XO175
> + return XO175
> elif os.path.exists('/etc/olpc-release'):
> return XO1
> else:
> @@ -763,3 +769,39 @@ def check_output(command, warning):
> print(warning)
> return None
> return output
> +
> +
> +def power_manager(status):
> + '''
> + Power Management
> + Use: power_manager(True) --> Disable power manager
> + power_manager(False) --> User custom power manager
> + '''
> +
> + # Constants
> + OHM_SERVICE_NAME = 'org.freedesktop.ohm'
> + OHM_SERVICE_PATH = '/org/freedesktop/ohm/Keystore'
> + OHM_SERVICE_IFACE = 'org.freedesktop.ohm.Keystore'
> + PATH = '/etc/powerd/flags/inhibit-suspend'
> +
> + if status:
> + VALUE = False
> + else:
> + VALUE = ACTUAL_POWER
> +
> + client.set_bool('/desktop/sugar/power/automatic', VALUE)
> +
> + try:
> + bus = dbus.SystemBus()
> + proxy = bus.get_object(OHM_SERVICE_NAME, OHM_SERVICE_PATH)
> + self._keystore = dbus.Interface(proxy, OHM_SERVICE_IFACE)
> + self._keystore.SetKey("suspend.automatic_pm", bool(VALUE))
> + except:
> + if status:
> + fd = open(PATH, "w")
> + fd.close()
> + if not status and ACTUAL_POWER:
> + try:
> + os.remove(PATH)
> + except OSError:
> + pass
> diff --git a/plugins/butia/butia.py b/plugins/butia/butia.py
> index f34201a..1bdaac8 100755
> --- a/plugins/butia/butia.py
> +++ b/plugins/butia/butia.py
> @@ -32,6 +32,7 @@ from TurtleArt.tapalette import make_palette
> from TurtleArt.talogo import primitive_dictionary, logoerror
> from TurtleArt.tautils import debug_output
> from TurtleArt.tawindow import block_names
> +from TurtleArt.tautils import power_manager
>
> from plugins.plugin import Plugin
>
> @@ -554,21 +555,27 @@ class Butia(Plugin):
> self.butia.set2MotorSpeed(sentLeft, abs(left), sentRight, abs(right))
>
> def moveButia(self, left, right):
> + power_manager(True)
> self.set_vels(left, right)
>
> def forwardButia(self):
> + power_manager(True)
> self.set_vels(self.actualSpeed[0], self.actualSpeed[1])
>
> def backwardButia(self):
> + power_manager(True)
> self.set_vels(-self.actualSpeed[0], -self.actualSpeed[1])
>
> def leftButia(self):
> + power_manager(True)
> self.set_vels(self.actualSpeed[0], -self.actualSpeed[1])
>
> def rightButia(self):
> + power_manager(True)
> self.set_vels(-self.actualSpeed[0], self.actualSpeed[1])
>
> def stopButia(self):
> + power_manager(False)
> self.set_vels(0, 0)
>
> def speedButia(self, speed):
> --
> 1.6.2.5
>
> _______________________________________________
> Butia-devel-l site list
> Butia-devel-l en fing.edu.uy
> https://www.fing.edu.uy/mailman/listinfo/butia-devel-l
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: https://www.fing.edu.uy/pipermail/butia-devel-l/attachments/20130222/ff13ad7e
Más información sobre la lista de distribución Butia-devel-l