Message2952

Author mehendran
Recipients
Date 2007-12-07.15:30:36
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
As you said, Yes,  I have already seen that platform,py is in CPythonLib and
significant work has been done in it.
I imported and tested platform module.
The output:
   test_architecture (__main__.PlatformTest) ... ERROR
   test_dist (__main__.PlatformTest) ... ok
   test_java_ver (__main__.PlatformTest) ... ('1.5.0', 'IBM Corporation', ('IBM J9 VM', '2.3', 'IBM Corporation'), (None, None, None)) ok
   test_libc_ver (__main__.PlatformTest) ... ERROR
   test_mac_ver (__main__.PlatformTest) ... ok
   test_machine (__main__.PlatformTest) ... ok
   test_node (__main__.PlatformTest) ... myhostname ok
   test_platform (__main__.PlatformTest) ... ERROR
   test_processor (__main__.PlatformTest) ...ok
   test_python_build (__main__.PlatformTest) ... ERROR
   test_python_compiler (__main__.PlatformTest) ... ERROR
   test_release (__main__.PlatformTest) ... 1.5.0 ok
   test_system (__main__.PlatformTest) ... Java ok
   test_system_alias (__main__.PlatformTest) ... ('Java', '1.5.0', 'IBM J9 VM, 2.3, IBM Corporation') ok
   test_uname (__main__.PlatformTest) ... ('Java', 'brajesh', '1.5.0', 'IBM J9 VM, 2.3, IBM Corporation', '', '') ok
   test_version (__main__.PlatformTest) ... IBM J9 VM, 2.3, IBM Corporation ok
   test_win32_ver (__main__.PlatformTest) ... ok


and it is not recognizing the actual underlying OS. its recognizing Java
as OS and retrives the details. From the above example it could be clear 
for you.

In CPython implementation, there are 5 functions which are not
required for Jython . they are python specific functions. 
   1. libc_ver()
   2. python_build()
   3. python_compiler()
   4. python_version()
   5. python_version_tuple()

In the platform patch, those functions had been replaced with   
   a. jython_compiler()
   b. jython_version()
   c. jython_version_tuple()

The output of cpython platform module.

$>  python Lib/test/test_platform.py
   test_architecture (__main__.PlatformTest) ... ('32bit', 'ELF') ok
   test_dist (__main__.PlatformTest) ... ok
   test_java_ver (__main__.PlatformTest) ... ('', '', ('', '', ''), ('', '', '')) ok
   test_libc_ver (__main__.PlatformTest) ... ('glibc', '2.3') ok
   test_mac_ver (__main__.PlatformTest) ... ok
   test_machine (__main__.PlatformTest) ... i686 ok
   test_node (__main__.PlatformTest) ... myhostname  ok
   test_platform (__main__.PlatformTest) ... Linux-2.6.16.46-0.14-bigsmp-i686-with-SuSE-10-i586 ok
   test_processor (__main__.PlatformTest) ... i686 ok
   test_python_build (__main__.PlatformTest) ... (3, 'Nov 29 2007 12:11:09') ok
   test_python_compiler (__main__.PlatformTest) ... ok
   test_release (__main__.PlatformTest) ... 2.6.16.46-0.14-bigsmp ok
   test_system (__main__.PlatformTest) ... Linux ok
   test_system_alias (__main__.PlatformTest) ... ('Linux', '2.6.16.46-0.14-bigsmp', '#1 SMP Thu May 17 14:00:09 UTC 2007') ok
   test_uname (__main__.PlatformTest) ... ('Linux', 'brajesh', '2.6.16.46-0.14-bigsmp', '#1 SMP Thu May 17 14:00:09 UTC 2007', 'i686', 'i686')ok
   test_version (__main__.PlatformTest) ... #1 SMP Thu May 17 14:00:09 UTC 2007 ok
   test_win32_ver (__main__.PlatformTest) ... ok

The output of platform module after my patch :-

   test_architecture (__main__.PlatformTest) ... ('', '') ok /* This is not yet implemented currently  
                                                            it just returns the empty tuple */
   test_dist (__main__.PlatformTest) ... ('SuSE', '10', 'i586') ok
   test_java_ver (__main__.PlatformTest) ... ('1.5.0', 'IBM Corporation', ('IBM J9 VM', '2.3', 'IBM Corporation'), (None, None, None)) ok
   test_jython_compiler (__main__.PlatformTest) ... java1.5.0 ok
   test_jython_version (__main__.PlatformTest) ... 2.3a0 ok
   test_jython_version_tuple (__main__.PlatformTest) ... ('2', '3', '0') ok
   test_mac_ver (__main__.PlatformTest) ... ('', ('', '', ''), '') ok
   test_machine (__main__.PlatformTest) ... i686 ok
   test_node (__main__.PlatformTest) ... myhostname ok
   test_platform (__main__.PlatformTest) ... Linux-2.6.16.46-0.14-bigsmp-i686-i686-with-SuSE-10-i586  ok
   test_processor (__main__.PlatformTest) ... i686 ok
   test_release (__main__.PlatformTest) ... 2.6.16.46-0.14-bigsmp ok
   test_system (__main__.PlatformTest) ... Linux ok
   test_system_alias (__main__.PlatformTest) ... ('Linux', '2.6.16.46-0.14-bigsmp', '#1 SMP Thu May 17 14:00:09 UTC 2007') ok
   test_uname (__main__.PlatformTest) ... ('Linux', 'brajesh', '2.6.16.46-0.14-bigsmp', '#1 SMP Thu May 17 14:00:09 UTC 2007', 'i686', 'i686') ok
   test_version (__main__.PlatformTest) ... #1 SMP Thu May 17 14:00:09 UTC 2007 ok
   test_win32_ver (__main__.PlatformTest) ... ('', '', '', '') ok

which actually matches the output of all the cpython platform module.

The actual problem is, its not recognising the actual OS( Linux,Mac,Win
etc) instead it recognizes java vm as platform and retrieves the values
of it.

we have reused most of the code from the cpython platform module and it
had been modified properly.

To make the module sync up with the CpythonLib 
1. we import platform from the CPythonLib to a new class and then
   tailoring the new class (but the module name will get changed)
2. we can generate the platform module by copying the important
   working CpythonLib platform module and with our functions.
3. we will rewrite everything in .java files

currently I am able to think of these solutions only..
I am sorry for ripping out the attribution and copyrights 
from the previous authors.

please send if there is any better way of doing this.

History
Date User Action Args
2008-02-20 17:18:53adminlinkissue1838658 messages
2008-02-20 17:18:53admincreate