Archived:How to use the PySymbian Envy module
The article is believed to be still valid for the original topic scope.
This articles show how to use the PySymbian "Envy" module. The module allows you to prevent Python scripts from closing in response to the device "red" key (or under low memory conditions). It also allows you to hide the app and run it as a background task, and to determine the capabilities available to the current script environment.
Article Metadata
Code Example
Compatibility
Article
Contents |
Overview
This article explains how to use the Python extension "Envy" by Cyke64.
Envy is mainly used to prevent the python application closing when the red/disconnect key is pressed or under low memory conditions (it sets the app as a "system app"). It also allows you to check what Platform security capabilities are available in the current scripting environment, and to make your application run as a background task - removing its icon from the system GUI and the task list.
The envy module is for 3rd Edition devices only. Download here:
Setting the script as a system app
The code below sets the script as a system app:
#importing the module envy
import envy
#Print version of envy
print envy.version
print envy.is_app_system()
try:
envy.set_app_system(1) # trying to set system your application
# (standalone) or python shell if you run it from there !
except:
print 'exception !' #exception encountered
print envy.is_app_system()
#After this code it the pythonshell would not exit
#on pressing the red/disconnect key
Checking capabilities of scripting environment
The code below shows how to tell what platform security capabilities are requested by your application, and what certificate the application is signed with.
from envy import *
# testing selfsigned
print has_capabilities(SELFSIGNED) # return 1 if True / 0 if false
print has_capabilities('selfsigned')
print has_capabilities('ALL-ReadDeviceData-WriteDeviceData-TrustedUI-ProtServ-SwEvent-Location-SurroundingsDD-PowerMgmt-NetworkControl-CommDD-MultimediaDD-DiskAdmin-DRM-TCB-AllFiles') print has_capabilities((ECapabilityReadUserData,ECapabilityWriteUserData,ECapabilityUserEnvironment,ECapabilityNetworkServices,ECapabilityLocalServices)) print has_capabilities('ReadUserData+WriteUserData+UserEnvironment+NetworkServices+LocalServices')
# testing unsigned
print has_capabilities('unsigned')
# testing your against any capabilities set
print has_capabilities('ALL-TCB-AllFiles')
# Display capacity in Python Script shell or your standalone application if running
#from this location !
print app_capabilities()
Set your application as background task
The envy extension can also make your application run as a background task - removing its icon from the system GUI and the task list.
importing the module envy
import envy
#Print version of envy
print envy.version
print envy.is_app_hidden()
try:
envy.set_app_hidden(1) # try to hide your application from tasklist
# (standalone) or python shell if you run it from there !
except:
print 'exception !'
print envy.is_app_hidden()
#Now pythonshell would have disappeared from the Taskbar/Tasklist.


09 Sep
2009