Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
138 user(s) are online (100 user(s) are browsing Forums)

Members: 2
Guests: 136

salass00, Swisso, more...

Headlines

 
  Register To Post  

Use timezone.library (or any library for that matter) in Python?
Just popping in
Just popping in


See User information
While I specifically want to use timezone.library, I'm interested mainly to know if it is possible to open any AmigaOS shared library in Python and call the functions?

Still trying to figure out how to set up some kind of automation around the DST issue for SMBFS so I won't have to manually edit my mounting script when DST changes. I know I can do all this in AREXX, but I'd like to give Python a try if there is a way to do it.

Oh, and don't bother suggesting that I use the datetime module in Python from OS 4.1. I checked and it does not deal with ANY timezone info whatsoever! All values and methods for datetime that return the timezone info (the .tzinfo stuff to be exact) return None as a value. I checked .dst and .utcoffset, which are the two main items I would need to make my script work.

Go to top
Re: Use timezone.library (or any library for that matter) in Python?
Just can't stay away
Just can't stay away


See User information
@dwolfman

While I specifically want to use timezone.library, I'm interested mainly to know if it is possible to open any AmigaOS shared library in Python and call the functions?
Timezone.library ? That's an Amiga lib. not a Python one. The shared library is "time.so" in sys:python/lib/lib-dyload.
I know I can do all this in AREXX
Because it calls Amiga librarys. Python is a independent system and calls on libs.so in Python. If you don't have the libs, then you don't have those functions.
Oh, and don't bother suggesting that I use the datetime module in Python from OS 4.1. I checked and it does not deal with ANY timezone info whatsoever!
Really? How do you say what you want in Python regarding time?

Go to top
Re: Use timezone.library (or any library for that matter) in Python?
Just popping in
Just popping in


See User information
@Snuffy

Quote:
Timezone.library ? That's an Amiga lib. not a Python one. The shared library is "time.so" in sys:python/lib/lib-dyload.

Exactly, I want to open an Amiga lib in Python and use functions in it. Is it possible?

Quote:
Because it calls Amiga librarys. Python is a independent system and calls on libs.so in Python. If you don't have the libs, then you don't have those functions.

OK, so is libs.so used to connect with an Amiga library? I'm not sure if I'm understanding this correctly.

Quote:
Really? How do you say what you want in Python regarding time?

Well, I tested it by using the python.org tutorial and references to get the results from the "tzinfo" methods and values under the datetime.module. In ALL cases, I received "None" for a value. Per python.org's documentation, that means NO timezone info is being used by Python at all. Here's what python.org says about datetime.tzinfo:
Quote:
datetime.tzinfo
The object passed as the tzinfo argument to the datetime constructor, or None if none was passed.


As you can see, it specifically states "None" means no timezone info was used by datetime for date and time calculations. Every function/value I tried that should return SOME kind of timezone information gives me "None" as a result, exactly as the python.org references explain when no timezone info is present.

I suspect the build was done without the timezone functionality enabled.

But I'm also not exactly clear on what you are asking me here. That last question isn't making much sense to me.

Go to top
Re: Use timezone.library (or any library for that matter) in Python?
Amigans Defender
Amigans Defender


See User information
@dwolfman
As you know, Python is written in C. What you do is create a Python module which calls the various AmigaOS functions. That is how the ARexx module works for example. So you can basically call any AmigaOS functions from Python as you like if you create a Python module.

Quote:
Oh, and don't bother suggesting that I use the datetime module in Python from OS 4.1.

Can you provide some Python test script which demonstrates what is wrong with the datetime module? There is a strong possibility it can be fixed. Please email the script to my personal email addy ssolie@telus.net. I don't like to use web forums to solve technical issues like this so please use email.

ExecSG Team Lead
Go to top
Re: Use timezone.library (or any library for that matter) in Python?
Just popping in
Just popping in


See User information
@ssolie

I don't have a script, as I was doing this testing from the interactive Python mode. I'll see if I can figure out what I typed to make it happen.

OK, figured out how to do it. According to the examples at Python.org, datetime.datetime.now() is supposed to return a datetime object with the tzinfo set to the current timezone info as used by the system, as I understand it. datetime.datetime.utcnow() returns a datetime with tzinfo set to None so it returns UTC time and not local time. While the functions return the correct time (now gives current local time, utcnow gives UTC time, which is different from local time), they both have the tzinfo attribute set to "None". Same for tzname and dst attributes/methods.

Here's how I did it in the Python console:
>>> import datetime
>>> d=datetime.datetime.now()     
>>> 
d2=datetime.datetime.utcnow()
>>> print 
d
2009
-09-02 18:27:29.273445
>>> print d2
2009
-09-02 23:27:31.536220
>>> print d.dst()                 
None
>>> print d2.dst()                
None
>>> print d.tzinfo                
None
>>> print d2.tzinfo               
None
>>> print d.tzname()              
None
>>> print d2.tzname()
None

Looks like I'm using AREXX again, since I know I can make this work over there. Either that or I'll compile a C program that uses Newlib to get me the timezone info. The Newlib functions are working fine, giving me correct info when it comes to the timezone stuff.

To be honest, the severe lack of Amiga-oriented documentation for a lot of the new stuff in OS4 is making this very frustrating. I can't get a program to compile with timezone.library, because I'm not including some include file that I can't find any documentation on.

Go to top
Re: Use timezone.library (or any library for that matter) in Python?
Just can't stay away
Just can't stay away


See User information
@dwolfman

#3
OK, so is libs.so used to connect with an Amiga library? I'm not sure if I'm understanding this correctly.
No. Python shared libraries -- .so are python compiled libraries. They have nothing to do with Amiga or AmigaDOS. Does that click=in?
Well, I tested it by using the python.org tutorial and references to get the results from the "tzinfo" methods and values under the datetime.module. In ALL cases, I received "None" for a value...

??? I use this in my 'Sys.log's:
import time
TI=time.strftime('%X %Z %x')
print TI ; quit()
"""5.1.6 DateTime-tzinfo.html
tzinfo is an abstract base class, meaning that this class should not be instantiated directly. You need to derive a concrete subclass, ... The datetime module does not supply any concrete subclasses of tzinfo."""

It should duplicate OS4.1 system time & date.

As you can see, it specifically states "None" means no timezone info..
???
I suspect the build was done without the timezone functionality enabled.
???
But I'm also not exactly clear on what you are asking me here. That last question isn't making much sense to me.
Do you speak Python? If you don't then your at a disadvantage. The Python 2.5 Docs in really deep.

Go to top
Re: Use timezone.library (or any library for that matter) in Python?
Just popping in
Just popping in


See User information
@Snuffy

Quote:

Snuffy wrote:
@dwolfman

No. Python shared libraries -- .so are python compiled libraries. They have nothing to do with Amiga or AmigaDOS. Does that click=in?

OK, then that takes care of using timezone.library from Python. Short answer: not possible without writing a module.

Quote:
??? I use this in my 'Sys.log's:
import time
TI=time.strftime('%X %Z %x')
print TI ; quit()
"""5.1.6 DateTime-tzinfo.html
tzinfo is an abstract base class, meaning that this class should not be instantiated directly. You need to derive a concrete subclass, ... The datetime module does not supply any concrete subclasses of tzinfo."""

It should duplicate OS4.1 system time & date.

Well, that gets the time, which I can already do with datetime module. What I'm trying to get is the timezone information. As in "is Daylight Savings Time in effect?" or "what timezone are we in?".

Quote:
Do you speak Python? If you don't then your at a disadvantage. The Python 2.5 Docs in really deep.

I guess the answer to that is, no I don't speak Python, yet. I'm just starting to learn it.

I agree that the docs aren't very good for beginners. However, I've been programming in multiple languages (BASIC, Pascal, C) for over 20 years now. Even that doesn't help with Python, because the reference documentation on Python.org is missing a lot of really necessary descriptions. For example, every other language reference I've ever seen gives full symantecs and syntax requirements for the language for each function. Python's documentation doesn't, which makes learning it very difficult and time consuming since I have to experiment to figure out what the specific usage of the functions are.

Go to top
Re: Use timezone.library (or any library for that matter) in Python?
Just popping in
Just popping in


See User information
@thread

I just looked through the time module (not datetime). Looks like I could use it to get the timezone/DST info. Those functions seem to work like they should.

Now I just need to get my head around Python. Anyone know any python docs that give better descriptions on usage than the ones at Python.org?

Go to top
Re: Use timezone.library (or any library for that matter) in Python?
Just popping in
Just popping in


See User information
@thread

OK, here's a prime example of why we need AMIGA-SPECIFIC documentation for this stuff.

According to Python.org, the time module has some variables and functions that do not exist in Python on my A1.

Specifically: time.timezone, time.tzname, time.tzset, and a few others

Sure, I can use time.localtime to get the DST flag, but I can't then use time.timezone or time.altzone to get the offsets for Standard and Daylight times, because they simply do not exist.

Yet when I have the time module spit out it's help info in OS 4.1's Python, it lists all of these as available. Why list it in the built-in help docs when it's not there?

This is the kind of garbage that is making me less inclined to learn Python. It's going to take me months to figure this out.

Go to top
Re: Use timezone.library (or any library for that matter) in Python?
Amigans Defender
Amigans Defender


See User information
@dwolfman
If you use email instead I may be able to help you.

ExecSG Team Lead
Go to top
Re: Use timezone.library (or any library for that matter) in Python?
Just popping in
Just popping in


See User information
@ssolie

Not sure why email would make any difference here...

In any case, I finally figured out how to get a C program compiled that makes use of the newlib time functions. That got me what I needed, which when combined with a DOS script and Docket gave me an automated way to deal with the DST time changes on my SMBFS mapped drives.

Learning Python for me can wait. I've not been able to get much more than a few piddly things done with the interpeted mode. Not much else is possible for me since the Python.org documentation for Python 2.5.1 (the version from OS4.1) still lists a bunch of stuff that's not available in the Amiga implementation. I'll look at Python again once we have decent Amiga-oriented documentation for it.

Go to top
Re: Use timezone.library (or any library for that matter) in Python?
Just can't stay away
Just can't stay away


See User information
@dwolfman

Quote:

To be honest, the severe lack of Amiga-oriented documentation for a lot of the new stuff in OS4 is making this very frustrating. I can't get a program to compile with timezone.library, because I'm not including some include file that I can't find any documentation on.


So why don't you ask for help in the SMBFS thread and post some of the code you've written and what the compiler is complaining about so that someone might actually be able to help you?

Have you included the "libraries/timezone.h" and "proto/timezone.h" files in your code?

#include <libraries/timezone.h>
#include <proto/timezone.h>

Go to top
Re: Use timezone.library (or any library for that matter) in Python?
Just popping in
Just popping in


See User information
@salass00

Well, I didn't save what I did with SMBFS that wasn't working, and that was several days ago. I think I had both those includes listed,but still was not able to get it to go. I'm also not one who usually asks for help, as I'd rather have the documentation in front of me when I'm working on something. Just the way I am I guess, since I learned how to program every language I've ever done that way.

What I've done now works. I made a simple command line util that uses newlib's localtime function to get the DST value and the current offset. It will do one of three things:
1) dump the output of asctime() that was fed the output of localtime(t), where t is the output of time(NULL).
2) give it the DST argument and it prints a 1 if DST is in effect or 0 if it is not. Also sets the shell return value to 0 if DST is not in effect and 5 (or WARN) if it is.
3) give it a ZONE argument and it dumps the value stored in tm_gmtoff from the localtime output.

With that I am using an if statement in a DOS script to deal with changing the DSTOFFSET parameter for my SMBFS command lines. So far it's working fine.

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project