marksull / fmcapi

A Python package designed to help users of Cisco's FMC interface with its API.
BSD 3-Clause "New" or "Revised" License
81 stars 57 forks source link

Python3.4, pip3 install fmcapi -U, f string causing errors #77

Closed lavermil closed 4 years ago

lavermil commented 4 years ago

Hello,

I love the project. I had a flawless working version from 2019 but recently upgraded to the latest. I found errors when doing a check of the package. The issue is related to the f string 3.6 feature you are now using for message formating. https://docs.python.org/3/whatsnew/3.6.html#pep-498-formatted-string-literals

Simple solution is to go to 3.6 but this server I am on I am not allowed to upgrade it.

I ran checks using: sudo python3 -m py_compile /usr/lib/python3.4/site-packages/fmcapi/fmc.py

I get errors back like: File "/usr/lib/python3.4/site-packages/fmcapi/api_objects/policy_services/accesspolicies.py", line 35 f"action, {action}, is not a valid option. Choose from {self.DEFAULT_ACTION_OPTIONS}."

Solution: If I go through all the package files and remove the f" or f' then I no longer have issues. I might be able to append .format() to each line.

It might be good to have a check/warning about python version.

daxm commented 4 years ago

Fair point. I'll make a note about being more specific with the versioning. That said, f-strings started around Python 3.6, which is "old" enough I felt it was okay to migrate to the new formatting method as all OSes (that I know of) are at 3.6+.

A possible alternative for you is to use Docker. We have a docker image that will run systems that have older versions of Python... that is, if you can run Docker. :-)