tyson-swetnam / porder

Simple CLI for Planet ordersV2 API
https://tyson-swetnam.github.io/porder/
Apache License 2.0
49 stars 12 forks source link

AttributeError: 'Namespace' object has no attribute 'func' for python 3.6 or greater #39

Closed rbavery closed 4 years ago

rbavery commented 4 years ago

Fresh installs of porder with python versions 3.6.7 or greater now bark when running porder

# rave at rave-thinkpad in ~/planet_tutorial [12:32:58]
→ porder                          
Traceback (most recent call last):
  File "/home/rave/miniconda3/envs/py3/bin/porder", line 8, in <module>
    sys.exit(main())
  File "/home/rave/miniconda3/envs/py3/lib/python3.6/site-packages/porder/porder.py", line 450, in main
    args.func(args)
AttributeError: 'Namespace' object has no attribute 'func'
(py3) 

I tested this on a python 2.7 environment and the error does not occur. To reproduce the error:

conda create -n py3 python=3.6 
conda activate py3
pip install porder datetimerange
porder

I'm not sure why this fails, being unfamiliar with argparse, but maybe this SO post helps? https://stackoverflow.com/questions/16878315/what-is-the-right-way-to-treat-python-argparse-namespace-as-a-dictionary

samapriya commented 4 years ago

Hi Ryan Can you try

porder -h

and let me know if that works?

rbavery commented 4 years ago

Hey Sam! In my python 3 env that works and so does porder version and porder quota

But while porder idlist works with python 2.7, it interprets args incorrectly with python 3

# rave at rave-thinkpad in ~/planet_tutorial on git:master ✖︎ [15:20:18]
→ porder quota idlist --input "/home/rave/planet_tutorial/san_pedro_section.geojson" --start "2019-06-01" --end "2019-06-08" --item "PSScene4Band" --asset "analytic_sr" --outfile "/home/rave/planet_tutorial/data/idlist.csv" --cmax ".05" --number "1" --overlap "100"
usage: porder [-h]
              {version,quota,shp2geojson,base64,simplify,idlist,difflist,idsplit,idcheck,bundles,order,ordersize,ostate,stats,download,multipart,multiproc}
              ...
porder: error: unrecognized arguments: idlist --input /home/rave/planet_tutorial/san_pedro_section.geojson --start 2019-06-01 --end 2019-06-08 --item PSScene4Band --asset analytic_sr --outfile /home/rave/planet_tutorial/data/idlist.csv --cmax .05 --number 1 --overlap 100
samapriya commented 4 years ago

Hi Ryan You tried to use two tools in the same line

porder quota idlist
porder quota is one tool and porder idlist is another

notice above

rbavery commented 4 years ago

oh YIKES, my b! It looks like idlist works on python 3 so that's good! I'm going to assume the only thing that doesn't behave is just running porder which isn't a big deal.

samapriya commented 4 years ago

Hi Ryan This has been fixed and the release 0.5.7 should work for porder without arguments. Closing this, for now, let me know if this reoccurs