python-jss

scraig
New Contributor II

Wanted to let everyone know about a python-jss module that I've been working on.

I have been using it for policy auditing within our organization. I have also used it to refactor Allister Banks' excellent autopkg addon for importing packages to the JSS and automatically building policies. This allowed me to start building in some of the features I wanted-like os_requirements and policy categories.

https://github.com/sheagcraig/python-jss

11 REPLIES 11

loceee
Contributor

I don't think this has generated the kind of hype it should of!

I am watching with great interest, would love to help, but my Python is pre-kindergarten level. There is some REALLY cool stuff here!

chriscollins
Valued Contributor

Digging into this myself. Quite awesome.

AndyBeaver
Contributor II

Awesome stuff!

luke_jaeger
Contributor

this looks like the very thing I need but I'm having a hell of a time getting started with it. Admittedly my Python skills are minimal but I'm comfy with the CLI generally.
I followed all the instructions for configuring python-jss etc. Tried this on a Mac at first and got pretty far into the weeds (possibly because the Mac I tested on has multiple Python versions, this being a Computer Science teaching lab). And I couldn't get around the "ImportError: no module named cryptography" error. Then I tried it on a clean Ubuntu box and I got farther, but I'm still confused about modules and what needs to be where. When I try to run spruce.py on the Linux system I get:

Traceback (most recent call last):
  File "./spruce.py", line 33, in <module>
    from Foundation import (NSData,
ImportError: No module named Foundation

Anyone know what I'm missing? thanks in advance --

chriscollins
Valued Contributor

@luke.jaeger I don't think you are going to be able to run that on a Linux box because the Foundation module is actually part of the PyObjC bridge to Cocoa, and is Mac specific. Though from what I remember Shea was using that primary to read in the settings file with the credentials for the JSS.

luke_jaeger
Contributor
I don't think you are going to be able to run that on a Linux box because the Foundation module is actually part of the PyObjC bridge to Cocoa, and is Mac specific.

Yup, you're right. With the help of someone who knows Python better than me, we got it working on a Mac. Cool! (As I suspected, the problem was Python path confusion)

Will this ever be turned into a Mac GUI app? That would be even more awesome.

chriscollins
Valued Contributor

You'd probably have to do it @luke.jaeger :) I'm not completely sure of this but I think the author is not using JAMF at his current place of employment anymore so it would be the community's job to do something with that ;)

luke_jaeger
Contributor

Does Spruce still work with JSS v 10.x? I keep getting 'SSL wrong version number' error when I try to run it. (And I had to set up a Python 2.7 installation to even get that far).

rtrouton
Release Candidate Programs Tester

@luke.jaeger ,

Spruce works with Jamf Pro 10.x (I used it last month to remove a number of obsolete packages from my AWS-hosted cloud distribution point.)

luke_jaeger
Contributor

would anyone be willing to look at my traceback and see if anything jumps out at you?

bethjohnson
New Contributor III

Luke, this time it's likely the TLS version setting within python-jss.

Here's the piece that got it working for me, from the python-jss issues on github:

Edit /Library/Python/2.7/site-packages/jss/tlsadapter.py
Find the line:
ssl_version=ssl.PROTOCOL_TLSv1

Change to:
ssl_version=ssl.PROTOCOL_TLSv1_2

That and I'm also using the jssimporter.py from the testing branch, but just making that change did not completely resolve it.

My errors were:

requests.exceptions.SSLError: HTTPSConnectionPool(host='JSSURLREDACTED', port=8443): Max retries exceeded with url: /JSSResource/distributionpoints (Caused by SSLError(SSLError(1, u'[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:590)'),))
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"You do not rise to the level of your goals; you fall to the level of your systems." James Clear