×

Discussion Board

Page 6 of 10 FirstFirst 12345678910 LastLast
Results 76 to 90 of 142

Thread: Python for UIQ

  1. #76
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    Any idea about why this does not work?

    Java code:
    Code:
    Power Monitor Sample Code
    /*
    * Copyright 1999 Sun Microsystems Inc, All rights reserved.
    */
    import javax.power.monitor.*;
    /**
    * Print the battery level and time remaining..
    */
    public class PowerSample1 {
    /**
    * Program to get and print the battery level and time remaining.
    */
    public static void main(String[] args) {
    // Get the system power monitor.
    PowerMonitor monitor = PowerMonitor.getInstance();
    // Get the current time and battery level.
    int remaining = monitor.getEstimatedSecondsRemaining();
    int level = monitor.getBatteryLevel();
    System.out.println("Battery Level = " + level +
    ", " + remaining + " seconds remaining.");
    if (remaining < 60) {
    System.out.println("Battery almost dead, better save your work.");
    }
    }
    }
    Jython code:
    >>> import javax.power.monitor.PowerMonitor
    >>> pm = javax.power.monitor.PowerMonitor
    >>> print pm.getBatteryLevel()
    TypeError:
    getBatteryLevel():
    expected 1 arg; not 0
    >>> print pm.getBatteryLevel(0)
    TypeError:
    getBatteryLevel(): self arg can't be coerced to

  2. #77
    Registered User
    Join Date
    Jan 2007
    Posts
    1

    Re: Python for UIQ

    it looks like getBatteryLevel needs self parameter, according to Python definition of instance methods. maybe, you should write pm.getBatteryLevel(pm)

  3. #78
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    Quote Originally Posted by 0d1n
    it looks like getBatteryLevel needs self parameter, according to Python definition of instance methods. maybe, you should write pm.getBatteryLevel(pm)
    does not work.

  4. #79
    Registered User
    Join Date
    Jul 2005
    Posts
    33

    Re: Python for UIQ

    Quote Originally Posted by cassioli
    Any idea about why this does not work?

    Java code:
    Code:
    Power Monitor Sample Code
    /*
    * Copyright 1999 Sun Microsystems Inc, All rights reserved.
    */
    import javax.power.monitor.*;
    /**
    * Print the battery level and time remaining..
    */
    public class PowerSample1 {
    /**
    * Program to get and print the battery level and time remaining.
    */
    public static void main(String[] args) {
    // Get the system power monitor.
    PowerMonitor monitor = PowerMonitor.getInstance();
    // Get the current time and battery level.
    int remaining = monitor.getEstimatedSecondsRemaining();
    int level = monitor.getBatteryLevel();
    System.out.println("Battery Level = " + level +
    ", " + remaining + " seconds remaining.");
    if (remaining < 60) {
    System.out.println("Battery almost dead, better save your work.");
    }
    }
    }
    Jython code:
    >>> import javax.power.monitor.PowerMonitor
    >>> pm = javax.power.monitor.PowerMonitor
    >>> print pm.getBatteryLevel()
    TypeError:
    getBatteryLevel():
    expected 1 arg; not 0
    >>> print pm.getBatteryLevel(0)
    TypeError:
    getBatteryLevel(): self arg can't be coerced to
    Try...
    >>> import javax.power.monitor.PowerMonitor
    >>> pm = javax.power.monitor.PowerMonitor.getInstance()
    >>> print pm.getBatteryLevel()
    >>> print pm.getEstimatedSecondsRemaining()
    and try...
    >>> print pm.usingExternalPowerSource()


    (I can't use JavaPhone,but it may work)
    Last edited by bpitk; 2007-01-25 at 15:55.

  5. #80
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    always the same
    damned,
    fucked,
    shitty
    error.

  6. #81
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    http://www.python.org/workshops/1997...s/hugunin.html
    1.1. Portable
    Java programs compile down to portable executable bytecodes that can run on any computer that supports a Java virtual machine. Unlike ANSI C, which achieves portability across platforms through recompilation of source files, Java's portability is available at the level of binary executables. This means that Java programs can be distributed as binary files that will run on any platform. While code written purely in Python currently enjoys this advantage and will run on any machine with a Python interpreter installed; the wealth of C-based Python extension modules, as well as the central Python interpreter itself, are only portable to multiple platforms after a (sometimes painful) recompilation of the C source.
    Can .py files be compiled directly to .class bytecode using Jython???
    Or I must wait for Jython to start every time I want to run a .py script?

  7. #82
    Registered User
    Join Date
    Jul 2005
    Posts
    33

    Re: Python for UIQ

    My Phone (p910i) can't use JavaPhone.
    When I put JavaPhone.jar in my phone,it ask for .dll,such as jPower.dll.
    But when I put jPower.dll in C:\system\libs of my phone,it still ask for jPower.dll !
    So I can't help You about JavaPhone.

    You are right about how to make Jython program start faster.
    Just compile it into .class(.jar).
    In my phone,this program run in Jython console within 20sec.
    http://isiam.blogspot.com/2007/01/jython06py.html
    But when compile it into .class(.jar),it use startup time only 5sec.
    You can test it by yourself.
    D/L this file into D:\jython06.jar of your UIQ.
    And run it with jRun,set jRun.txt into "-cp D:\jython;D:\jython06.jar jython06".
    http://isiam.info/dl/Jython06.zip
    How to compile it into .class(.jar)...
    Install JDK1.1.8 and jython2.1 on your PC.
    And use "jythonc.bat" with this command...
    Code:
    jythonc -j jython06.jar jython06.py
    This command will compile jython06.py into .class(in jython06.jar).
    And this process should be done on jdk1.1.8.(It'll be confused,if you have many JDK on your PC.)
    And if you use "jythonc.bat" with this command...
    Code:
    jythonc -a -j jython06.jar jython06.py
    No need pre-install Jython on UIQ to run this jython06.jar.
    Because this command will compile jython06.py into .class(in jython06.jar),and add all Jython package in it.
    Jython file(jython06.py~1.2k) increased size to 340k,but it's faster on UIQ.

  8. #83
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    Quote Originally Posted by bpitk
    My Phone (p910i) can't use JavaPhone.
    When I put JavaPhone.jar in my phone,it ask for .dll,such as jPower.dll.
    But when I put jPower.dll in C:\system\libs of my phone,it still ask for jPower.dll !
    So I can't help You about JavaPhone.
    it's a pity... for both of us!

    And run it with jRun,set jRun.txt into "-cp D:\jython;D:\jython06.jar jython06".
    http://isiam.info/dl/Jython06.zip
    I had an idea:
    are you able to write a little .py script which just ask user for a python script and the runs it? If I'm understanding jython correctly, it should be a matter of no more than 5 code lines!
    In meta-language:
    - show input-dialog
    - write proper line into jRun.txt
    - launch jRun

    This would make a lot easier testing our jython applications.

    An even simpler launcher could be a program which shows a list of available .py files allowing to select which one must be launched.
    If you point me to the right python statements, I'll try to implement both of these programs by myself (it's just a good chance to learn a bit of jython programming).


    How to compile it into .class(.jar)...
    Install JDK1.1.8 and jython2.1 on your PC.
    And use "jythonc.bat" with this command...
    Code:
    jythonc -j jython06.jar jython06.py
    This command will compile jython06.py into .class(in jython06.jar).
    And this process should be done on jdk1.1.8.(It'll be confused,if you have many JDK on your PC.)
    I know about a "-target 1.1" parameters accepted by javac; maybe jythonc accepts it too and passes it to javac?

    No need pre-install Jython on UIQ to run this jython06.jar.
    My (possible) users will be glad of this!

    Thank you very much for all your efforts about this issue.

  9. #84
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    btw, how can I run JythonQ on the emulator? Testing would be much faster! But currently emulator just crashes 20 secs after clicking JythonQ icon...

  10. #85
    Registered User
    Join Date
    Jul 2005
    Posts
    33

    Re: Python for UIQ

    It's not easy to debug Jython on UIQ.
    If your code error,it make console crashed.

    If you try to write Jython program that may cause severe error,try it on pc first.
    To try Jython Program on UIQ.
    Just replace the line...
    Code:
    java.lang.System.exit(0)
    with...
    Code:
    self.dispose()
    (if your class is Inheriting from java.awt.Frame)

    I can't I run JythonQ on the emulator,too.

  11. #86
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    Quote Originally Posted by bpitk
    It's not easy to debug Jython on UIQ.
    If your code error,it make console crashed.

    If you try to write Jython program that may cause severe error,try it on pc first.
    To try Jython Program on UIQ.
    Just replace the line...
    Code:
    java.lang.System.exit(0)
    with...
    Code:
    self.dispose()
    (if your class is Inheriting from java.awt.Frame)
    I donìt know at all how to use jython on PC...

    I can't I run JythonQ on the emulator,too.
    I just read that launching PEPOC rather than EPOC.exe should result in launching a special version of the emulator that:
    - does not crash in case of java exception
    - show on DOS console the java console output

    ...but "of course" on my system launching PEPOC results in... NOTHING HAPPENS (not even an error message)!

    Maybe you'll have better luck.

  12. #87
    Registered User
    Join Date
    Jul 2005
    Posts
    33

    Re: Python for UIQ

    Quote Originally Posted by bpitk
    To try Jython Program on UIQ.
    Just replace the line...
    Code:
    java.lang.System.exit(0)
    with...
    Code:
    self.dispose()
    (if your class is Inheriting from java.awt.Frame)
    Replace that line(above),will keep Jython awtConsole(on UIQ) open,not shut down with Jython program(.py).

  13. #88
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    Quote Originally Posted by bpitk
    Replace that line(above),will keep Jython awtConsole(on UIQ) open,not shut down with Jython program(.py).
    ah, clear now. thanks.
    but I'm currently busy getting crazy with getting javaphone working... Looks like there are A LOT of undocumented features I must explore.
    I'm on messenger for a while, if you have a bit of spare time. cassioli ai iol dot it .

  14. #89
    Registered User
    Join Date
    Jul 2005
    Posts
    33

    Re: Python for UIQ

    I'm currently busy getting crazy with getting javaphone working... Looks like there are A LOT of undocumented features I must explore.
    Try java.lang.reflection,it work for my problem like that.

    I have got the idea,I compiled awtcon.py.
    Now it reduced startup time into 11sec(on my phone).
    (May be... if extract it into .class&Folders may be faster than 11sec.)
    But it not work accurately(can't import some module).
    I need more time to work arounded this problem.
    (If I can transform awtcons.py into .class (or by manual coding),it may improve startup time.)
    Last edited by bpitk; 2007-01-28 at 16:34.

  15. #90
    Super Contributor
    Join Date
    Mar 2003
    Posts
    580

    Re: Python for UIQ

    Quote Originally Posted by bpitk
    I have got the idea,I compiled awtcon.py.
    Now it reduced startup time into 11sec(on my phone).
    (May be... if extract it into .class&Folders may be faster than 11sec.)

    D/L this file...
    http://isiam.info/dl/awtcons03.zip
    and place awtcons.jar in D:\jython (of UIQ)
    Change JythonQ.txt into...
    Code:
    -cp D:\jython\awtcons.jar;D:\jython -Dpython.home=D:\jython awtcons
    I guess there is a mistake in this line, JythonQ does not start anymore now!
    Last edited by cassioli; 2007-01-28 at 16:35.

Similar Threads

  1. Please help installing Python libraries on S60
    By ericroijen in forum Symbian
    Replies: 11
    Last Post: 2009-07-18, 10:43
  2. Python for Series 60 released on Forum Nokia!
    By eriksmartt in forum Symbian
    Replies: 5
    Last Post: 2009-07-14, 17:00
  3. Python 2.2? 2.3?
    By mflux in forum Symbian
    Replies: 3
    Last Post: 2006-06-26, 22:36
  4. Python C++ Extension with Callback crashing
    By diggerdeep in forum Symbian
    Replies: 2
    Last Post: 2005-11-10, 16:33
  5. Replies: 0
    Last Post: 2004-07-18, 00:56

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×