ChristianTremblay / pyhaystack

Pyhaystack is a module that allow python programs to connect to a haystack server project-haystack.org. Connection can be established with Niagara Platform running the nhaystack, Skyspark and Widesky. For this to work with Anaconda IPython Notebook in Windows, be sure to use "python setup.py install" using the Anaconda Command Prompt in Windows. If not, module will be installed for System path python but won't work in the environment of Anaconda IPython Notebook. You will need hszinc 1.3+ for this to work.
Apache License 2.0
73 stars 31 forks source link

Failing to log in to SkySpark with correct credentials #14

Closed candronikos closed 8 years ago

candronikos commented 8 years ago

Tried testing with some simple code with skyspark with the code at the bottom of this issue. The result is posted below:

RESULT

False
<GetGridOperation failed>

CODE

from pyhaystack.client.skyspark import SkysparkHaystackSession
session = SkysparkHaystackSession(uri='http://url_to_server',
                                username='myusername',
                                password='secretpassword',
                                project = 'project')

if(__name__ == '__main__'):
    about = session.about()
    print(session.is_logged_in)
    print(about)
ChristianTremblay commented 8 years ago

Thanks for reaching us.

I've tried your snippet using niagara client and it works. Unfortunately, I don't have actually an access to a Skyspark server. Would you accept to share your login info in private ? I would then be able to look at it. My email is in my Github profile

candronikos commented 8 years ago

Hi,

I might be able to create an account on the demo project and hand you the details. I'll see if I can get permission to do this.

candronikos commented 8 years ago

Hi Christian,

I have just created a temp account and sent you the details

ChristianTremblay commented 8 years ago

Actively working on

sjlongland commented 8 years ago

Is there any publicly visible documentation for SkySpark? I'll admit I ported the old needle sources to the new API blindly, I don't have access to a SkySpark server to test on.

I recall looking on their website for details but didn't see any.

candronikos commented 8 years ago

beyon-d.net seems to be up to date

sjlongland commented 8 years ago

Ahh, that's why I didn't spot it, completely different site. :-)

https://www.beyon-d.net/doc/docSkySpark/Rest.html#auth would have been a big help.

ChristianTremblay commented 8 years ago

@candronikos Please have a look to : https://github.com/ChristianTremblay/pyhaystack/tree/skyspark_login

I'm able to login, retrieve site, about... but I have some problems with find_entity. Seems to be related to hszinc... I'll give credentials to @sjlongland so he can make tests.

ChristianTremblay commented 8 years ago

Forgot one detail : it works on Python 3.... we'll have a look to make it work with Python 2

candronikos commented 8 years ago

Tested the code on my machine. Looks good so far! I removed the details of the response body for privacy but they're correct.

Also, I'm using Python 3 anyway so it's not a problem for me

<GetGridOperation done: <Grid>
    Columns:
        productUri
        whoami
        serverBootTime
        projName
        tz
        moduleName
        serverName
        productName
        haystackVersion
        productVersion
        moduleVersion
        serverTime
        hostModel
    Row    0: ""DETAILS_HIDDEN""
</Grid>>
ChristianTremblay commented 8 years ago

Troubles appears with : sensors = session.find_entity(filter_expr='sensor').result

You can join gitter to share more details : https://gitter.im/ChristianTremblay/pyhaystack

sjlongland commented 8 years ago

hszinc is tripping up on the grid that gets returned by SkySpark. A simple read of site entities worked, but not equips, there's something there that the parser doesn't like.

I've grabbed a copy of the offending grid and I'll have a look when I get a chance. In the meantime, you can force pyhaystack to use JSON serialisation by using the following:

import hszinc
from pyhaystack.client.skyspark import SkysparkHaystackSession
session = SkysparkHaystackSession(uri='http://xxx',
                         username='xxx, password='xxx, project='xxx', grid_format=hszinc.MODE_JSON)

This is not ideal, but it might get you going.

ChristianTremblay commented 8 years ago

Remaining bug : Make Python 2 & 3 work string encoding is giving me a hard time. https://github.com/ChristianTremblay/pyhaystack/tree/skyspark_login

ChristianTremblay commented 8 years ago

https://github.com/ChristianTremblay/pyhaystack/commit/578b2691638fa6ac1da20ce803dc3b7b951e8907

Solve the Python 2/3 compatibility

jjproe commented 7 years ago

Hello. I need a Python 2.6 to Skyspark interface. I try long to make it runable. But i have the same Problem with failed

ChristianTremblay commented 7 years ago

I can't guaranty it'll work on 2.6 as we use a lot of features that are 2.7-3. Can you be more precise about the bugs you meet ? Also, be sure to make your tests with dev branch as some bugs have been noticed in Skyspark with master branch.

If it appears to be version related, please open another issue.

sjlongland commented 7 years ago

I would seriously not bother with Python 2.6. Most platforms have moved on from that release, the only OSes I can think of that depend on that release are circa 2010 or earlier, which should be considered unsupported security liabilities.

Python 2.7 is still supported because Python 3.x support was in its infancy until very recently on most Linux distributions (IMO it's a mess in Debian even in Jessie), and really is on borrowed time: the upstream Python project wants to kill off the 2.x branch.

If you're starting from scratch, I'd seriously recommend going to Python 3.4 or later if possible, as this was the first of the 3.x series that was particularly well supported. If backward compatibility with Python 2 modules is needed, then recent 2.7 is the best option.

jjproe commented 7 years ago

Thanks, but the system i will connect runs under SLES 11 (python 2.6.5). I had read something about "python" environments.. and the possibility to run both Versions.. But the effort is too big for me...

I only will get a points-list from SkysPark and perhaps import points from foreign system..

My idea is to minimize your pyhaystack (only communication to SyksPark).. I don't need numpy or other numerical manipulations under python.. And if hszinc make trouble to run under this python Version, i'll change to json...

Are my reflections OK ?

2016-10-30 3:19 GMT+01:00 Stuart Longland notifications@github.com:

I would seriously not bother with Python 2.6. Most platforms have moved on from that release, the only OSes I can think of that depend on that release are circa 2010 or earlier, which should be considered unsupported security liabilities.

Python 2.7 is still supported because Python 3.x support was in its infancy until very recently on most Linux distributions (IMO it's a mess in Debian even in Jessie), and really is on borrowed time: the upstream Python project wants to kill off the 2.x branch.

If you're starting from scratch, I'd seriously recommend going to Python 3.4 or later if possible, as this was the first of the 3.x series that was particularly well supported. If backward compatibility with Python 2 modules is needed, then recent 2.7 is the best option.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChristianTremblay/pyhaystack/issues/14#issuecomment-257127854, or mute the thread https://github.com/notifications/unsubscribe-auth/ATDM0RWdpFxoFpv01Zl6JzEXaDRv-kbFks5q4_7EgaJpZM4IqNzN .

sjlongland commented 7 years ago

On 31/10/16 20:50, jjproe wrote:

And if hszinc make trouble to run under this python Version, i'll change to json...

Won't make a sceric of difference. hszinc is used in both modes, just in ZINC mode it does its own serialisation/deserialisation, whereas in JSON mode, the json module does the heavy lifting.

The same classes are used to represent values in both modes.

There's talk of a Python 2.7 binary as part of the OpenSuSE distribution: https://forums.suse.com/showthread.php?5293-Python-2-7-for-SLES-11-SP3

SLES 11 is quite dated by the looks of things, so you likely won't see anything official in terms of Python 2.7 or 3.x. SLES 12 might be worth investigating, the other option might be to look at Docker and running a

newer Python environment in a container.

Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind... ...it's backed up on a tape somewhere.

ChristianTremblay commented 7 years ago

Locking the issue and linking here : https://github.com/ChristianTremblay/pyhaystack/issues/31