Skip to content
James Reynolds edited this page Feb 17, 2022 · 21 revisions

Development Server

We "highly" recommend that you set up a Jamf Pro development server testing python-jamf module or anything experimental or major changes on a development server before implementing it on your production server. In case something unexpected happens it only happens development server and NOT your production server.

For example, if you are a Jamf Cloud customer you can get a "sandbox" server that you can experiment and test things before moving to production. Or for on-premise instances, you get a "sandbox" license that you can set up in your server infrastructure.

Docker

Using Docker Desktop on a Mac system, you can set up a Jamf Pro "sandbox" using docker-compose, and that you can quickly set up and teardown without additional server infrastructure.

Docker for Mac Jamf Pro Sandbox Server

See the following GitHub repository here for instructions on this process.

Or here is an in-depth presentation, Docker for Beginners by James Reynolds at the University of Utah, MacAdmins meeting.

Running Tests

The following doesn't work as of 2020/12.

cd python-jamf

# runs all tests
python3 -m unittest discover -v

# run tests individually
python3 -m python-jamf.tests.test_api
python3 -m jamf.tests.test_config
python3 -m jamf.tests.test_convert
python3 -m jamf.tests.test_package

If you see an error that says something like SyntaxError: invalid syntax, check to see if you're using python3.

Troubleshooting

Errors

Receiving errors using different aspects of python-jamf?

Here are some common errors and how to fix them:

Which python-jamf is Python using?

With Python having different locations where site-packages can be stored, it can be a difficult to make sure that it is using the correct version. Python-jamf is located in one of the site-package directories. To find the location we have to look at how Python uses site-packages. Python has a hierarchical list of directories it checks for the library. The list can be found by using Python's site command.

python3 -m site
List Site-Package Directories

This produces the list of site-package directories Python checks.

% python3 -m site
sys.path = [
   '/Users/topher/Documents/GitHub/jctl',
   '/Library/Frameworks/Python.framework/Versions/3.8/lib/python38.zip',
   '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8',
   '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload',
   '/Users/topher/Library/Python/3.8/lib/python/site-packages',
   '/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages',
]
USER_BASE: '/Users/topher/Library/Python/3.8' (exists)
USER_SITE: '/Users/topher/Library/Python/3.8/lib/python/site-packages' (exists)
ENABLE_USER_SITE: True

The top directory in the list is the first place that Python tries to find the particular site-package. Perform a list on the directory and see if you find "jamf" or "python-jamf" there. "jamf" was the old name that was installed pre-0.4.0. Continue down the list until you have reached where pip has installed python-jamf for you.

To figure out where pip has installed python-jamf for you, use this command:

pip show python-jamf

In location it will display where PIP has installed python-jamf.

% pip show python-jamf
Name: python-jamf
Version: 0.4.7
Summary: Python wrapper for Jamf Pro API
Home-page: https://github.com/univ-of-utah-marriott-library-apple/python-jamf
Author: The University of Utah
Author-email: [email protected]
License: UNKNOWN
Location: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages
Requires: requests
Required-by:

By the time that you have reached the pip installed directory, the other python-jamf should have been discovered.

Contributors

  • Sam Forester
  • James Reynolds
  • Topher Nadauld
  • Tony Williams
  • O'Ryan Hampton
  • Richard Glaser
Clone this wiki locally