rmnl / clack

Clack is a Command Line API Calling Kit for JW Player API's based on Click
MIT License
7 stars 2 forks source link

Options are broken #8

Closed jlieb10 closed 7 years ago

jlieb10 commented 7 years ago

I tried:

$clack call --csv-file ./tagskeys4_sample.csv /videos/update "{'video_key': '<<Key>>', 'custom.category': '<<Category>>', 'custom.series': '<<Series>>'}"

It returned:

Error: no such option: --csv-file

I dug into the code a bit and tried the alternative:

$clack call -c ./tagskeys4_sample.csv /videos/update "{'video_key': '<<Key>>', 'custom.category': '<<Category>>', 'custom.series': '<<Series>>'}"

It returned:

Error: no such option: -c

Then, just to see if any options worked:

$clack call -o
Error: no such option: -o

$clack call -v
Error: no such option: -v

I'm using the most recent version of Clack in a virtualenv per the documentation on Github.

rmnl commented 7 years ago

@jlieb10 What version of clack are you running? Version 2.0.0b8 is the latest.

~ ❯ clack --version                                                                                                                                                                                        Clack-2.0.0b8
jlieb10 commented 7 years ago

@rmnl

(CLACK) 12:13 jlieberman ~/CLACK 
$clack --version
Clack-1.0.0

(CLACK) 12:13 jlieberman ~/CLACK 
$pip install --upgrade clack-cli

Requirement already up-to-date: clack-cli in ./lib/python2.7/site-packages
Requirement already up-to-date: urllib3>=1.10.1 in ./lib/python2.7/site-packages (from clack-cli)
Requirement already up-to-date: keyring>=5.7.1 in ./lib/python2.7/site-packages (from clack-cli)
Requirement already up-to-date: httplib2>=0.9 in ./lib/python2.7/site-packages (from clack-cli)
Requirement already up-to-date: Click>=5.0 in ./lib/python2.7/site-packages (from clack-cli)

(CLACK) 12:14 jlieberman ~/CLACK 
$clack --version
Clack-1.0.0

(CLACK) 12:14 jlieberman ~/CLACK 
$pip install https://pypi.python.org/packages/04/35/f312db48df937cf10d068fe3314667e120007a5411db6a88c0079cbec6f0/clack-cli-2.0.0b8.tar.gz#md5=8a1a0c9522c1046060f67c6d2f995cea
Collecting https://pypi.python.org/packages/04/35/f312db48df937cf10d068fe3314667e120007a5411db6a88c0079cbec6f0/clack-cli-2.0.0b8.tar.gz#md5=8a1a0c9522c1046060f67c6d2f995cea
  Downloading clack-cli-2.0.0b8.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/5r/9lr2kkkd4p3930_qn_bkmn3mq16g0_/T/pip-9oIsmY-build/setup.py", line 3, in <module>
        with open('description.rst') as f:
    IOError: [Errno 2] No such file or directory: 'description.rst'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/5r/9lr2kkkd4p3930_qn_bkmn3mq16g0_/T/pip-9oIsmY-build/

I'm not a Python dev so maybe I'm doing something wrong? Just working with the documentation and my limited knowledge of pip.

jlieb10 commented 7 years ago

@rmnl So, I downloaded and decompressed the package locally and commented out the 3 lines in setup.py that reference description.rst/long_description and installed it successfully

Now I'm having this issue where it's not parsing my csv correctly- You'll see when I run the csv command to update, it's not correctly finding the values but when I run show w/ one of the video ids, it does find it successfully

(CLACK) 12:37 jlieberman ~/CLACK 
$clack call --csv-file ./tagskeys4_sample.csv /videos/update "{'video_key': '<<Key>>', 'custom.category': '<<Category>>', 'custom.series': '<<Series>>'}"
Call settings:                                                                                                                                                

api type       : ms1
api host       : https://api.jwplatform.com
verify ssl     : True
endpoint       : videos/update
params         : {'video_key': '<<Key>>', 'custom.category': '<<Category>>', 'custom.series': '<<Series>>'}
key/username   : *********
secret         : ********
output format  : py
batch csv file : /Users/jlieberman/CLACK/tagskeys4_sample.csv

Calling API  [####################################]  100%             
Call output:                                                                                                                                                  
{
    "1Jjwmt4M": "Error: u'video_key: Video with the key <<Key>> does not exist'", 
    "2zMhLCCJ": "Error: u'video_key: Video with the key <<Key>> does not exist'", 
    "MM2WPkDg": "Error: u'video_key: Video with the key <<Key>> does not exist'", 
    "UaMFiUMN": "Error: u'video_key: Video with the key <<Key>> does not exist'", 
    "fN74C6H9": "Error: u'video_key: Video with the key <<Key>> does not exist'", 
    "lSfRduIO": "Error: u'video_key: Video with the key <<Key>> does not exist'", 
    "w7Mfq9Ts": "Error: u'video_key: Video with the key <<Key>> does not exist'", 
    "wPK1CrU9": "Error: u'video_key: Video with the key <<Key>> does not exist'"
}

(CLACK) 12:41 jlieberman ~/CLACK 
$clack call /videos/show "{'video_key': '1Jjwmt4M'}"
Call settings:                                                                                                                                                

api type      : ms1
api host      : https://api.jwplatform.com
verify ssl    : True
endpoint      : videos/show
params        : {'video_key': '1Jjwmt4M'}
key/username  : *********
secret        : ********
output format : py

Response:                                                                                                                                                     
{
    "rate_limit": {
        "limit": 60, 
        "remaining": 59, 
        "reset": 1490186580
    }, 
    "status": "ok", 
    "video": {
        "author": "drew.anthony.smith@gmail.com", 
        "custom": {
            "batch": "full_migration", 
            "legacy_id": "6c6696dcaee35", 
            "thumbnail_url": "https://a.fastcompany.net/multisite_files/codesign/article_feature/1280-ouverture-de-la-bouche.jpg"
        }, 
        "date": 1336663503, 
        "description": "A look inside the mummies’ tombs, compliments of Harvard, Boston’s MFA, and Dassault Systèmes.", 
        "duration": "98.82", 
        "error": null, 
        "expires_date": null, 
        "key": "1Jjwmt4M", 
        "link": "http://www.fastcodesign.com/1669729/a-new-virtual-tour-of-giza-lets-you-sidle-up-close-to-the-pharaoh", 
        "md5": "4276fe18bccd8659a1a166d3e495f33d", 
        "mediatype": "video", 
        "size": "111524561", 
        "sourceformat": null, 
        "sourcetype": "file", 
        "sourceurl": null, 
        "status": "ready", 
        "tags": "2-d, cliff kuang, dassault, egypt, fastcodesign.com, giza, harvard, interactive, pyramids, slideshow, twistage-6c6696dcaee35", 
        "title": "A New, Virtual Tour Of Giza Lets You Sidle Up Close To The Pharaoh", 
        "trim_in_point": null, 
        "trim_out_point": null, 
        "updated": 1476128837, 
        "upload_session_id": null, 
        "views": 42
    }
}
jlieb10 commented 7 years ago

@rmnl also doing update on a single video works as expected - could you send me an example csv you've used to test this? perhaps mine is structured in an incorrect way for your parsing?

(CLACK) 12:49 jlieberman ~/CLACK 
$clack call /videos/update "{'video_key': '1Jjwmt4M', 'custom.category':'misc', 'custom.series':'video'}"
Call settings:                                                                                                                                                

api type      : ms1
api host      : https://api.jwplatform.com
verify ssl    : True
endpoint      : videos/update
params        : {'video_key': '1Jjwmt4M', 'custom.category':'misc', 'custom.series':'video'}
key/username  : *********
secret        : ********
output format : py

Response:                                                                                                                                                     
{
    "rate_limit": {
        "limit": 60, 
        "remaining": 59, 
        "reset": 1490187240
    }, 
    "status": "ok"
}

(CLACK) 12:53 jlieberman ~/CLACK 
$clack call /videos/show "{'video_key': '1Jjwmt4M'}"
Call settings:                                                                                                                                                

api type      : ms1
api host      : https://api.jwplatform.com
verify ssl    : True
endpoint      : videos/show
params        : {'video_key': '1Jjwmt4M'}
key/username  : *********
secret        : ********
output format : py

Response:                                                                                                                                                     
{
    "rate_limit": {
        "limit": 60, 
        "remaining": 58, 
        "reset": 1490187240
    }, 
    "status": "ok", 
    "video": {
        "author": "drew.anthony.smith@gmail.com", 
        "custom": {
            "batch": "full_migration", 
            "category": "misc", 
            "legacy_id": "6c6696dcaee35", 
            "series": "video", 
            "thumbnail_url": "https://a.fastcompany.net/multisite_files/codesign/article_feature/1280-ouverture-de-la-bouche.jpg"
        }, 
        "date": 1336663503, 
        "description": "A look inside the mummies’ tombs, compliments of Harvard, Boston’s MFA, and Dassault Systèmes.", 
        "duration": "98.82", 
        "error": null, 
        "expires_date": null, 
        "key": "1Jjwmt4M", 
        "link": "http://www.fastcodesign.com/1669729/a-new-virtual-tour-of-giza-lets-you-sidle-up-close-to-the-pharaoh", 
        "md5": "4276fe18bccd8659a1a166d3e495f33d", 
        "mediatype": "video", 
        "size": "111524561", 
        "sourceformat": null, 
        "sourcetype": "file", 
        "sourceurl": null, 
        "status": "ready", 
        "tags": "2-d, cliff kuang, dassault, egypt, fastcodesign.com, giza, harvard, interactive, pyramids, slideshow, twistage-6c6696dcaee35", 
        "title": "A New, Virtual Tour Of Giza Lets You Sidle Up Close To The Pharaoh", 
        "trim_in_point": null, 
        "trim_out_point": null, 
        "updated": 1490187187, 
        "upload_session_id": null, 
        "views": 42
    }
}
rmnl commented 7 years ago

@jlieb10 Try installing it from pip once too. Use the following command to install the latest version because pip will not install beta releases automatically.

pip install --upgrade clack-cli==2.0.0b8
jlieb10 commented 7 years ago

@rmnl that works fine- I reinstalled with the command above but it's still not working with my csv file. Can you do a test on your machine to see if a /videos/update batch call works for you?

$clack call --csv-file ./tagskeys4_sample.csv /videos/update "{'video_key': '<<key>>', 'custom.category': '<<category>>', 'custom.series': '<<series>>'}"
Call settings:                                                                  

api type       : ms1
api host       : https://api.jwplatform.com
verify ssl     : True
endpoint       : videos/update
params         : {'video_key': '<<key>>', 'custom.category': '<<category>>', 'custom.series': '<<series>>'}
key/username   :**********
secret         : ********
output format  : py
batch csv file : /Users/jlieberman/CLACK/tagskeys4_sample.csv

Calling API  [####################################]  100%             
Call output:                                                                    
{
    "1Jjwmt4M": "Error: u'video_key: Video with the key <<key>> does not exist'", 
    "2zMhLCCJ": "Error: u'video_key: Video with the key <<key>> does not exist'", 
    "MM2WPkDg": "Error: u'video_key: Video with the key <<key>> does not exist'", 
    "UaMFiUMN": "Error: u'video_key: Video with the key <<key>> does not exist'", 
    "fN74C6H9": "Error: u'video_key: Video with the key <<key>> does not exist'", 
    "lSfRduIO": "Error: u'video_key: Video with the key <<key>> does not exist'", 
    "w7Mfq9Ts": "Error: u'video_key: Video with the key <<key>> does not exist'", 
    "wPK1CrU9": "Error: u'video_key: Video with the key <<key>> does not exist'"
}

CSV as plaintext:

key,tags,series,category
fN74C6H9,"1aeada7a787bd,article,d4954e10b3193,fastcompany.com,fastcompanycom,most-creative-people,people,rebecca-greenfield,twistage-1aeada7a787bd,",video,misc
UaMFiUMN,"1one,advertising,article,fastcocreate.com,fastcocreatecom,innovation,jeff-beer,lg2,marketing,twistage-c7c8d16264de5,",video,misc
w7Mfq9Ts,"2-d,art,article,artists,creative-process,fastcodesign.com,fastcodesigncom,innovation,mark-wilson,painting,patrick-peris,portraiture,steve-spazuk,twistage-f4daf75568415,",video,misc
1Jjwmt4M,"2-d,cliff-kuang,dassault,egypt,fastcodesign.com,giza,harvard,interactive,pyramids,slideshow,twistage-6c6696dcaee35,",video,misc
2zMhLCCJ,"2-minute-turnaround-brought-to-you-by-american-express-open-forum,advertorial,bryan-neilon,fastcompany.com,fastcompanycom,twistage-69ab7b1b21a4a,watch,",*american_express,advertorial
lSfRduIO,"2-minute-turnaround-brought-to-you-by-american-express-open-forum,advertorial,bryan-neilon,fastcompany.com,fastcompanycom,twistage-fd97352ea2b81,watch,",*american_express,advertorial
wPK1CrU9,"2-minute-turnaround-brought-to-you-by-american-express-open-forum,advertorial,fastcompany.com,fastcompanycom,fc-studios,twistage-012dbb3d67ca8,watch,",*american_express,advertorial
MM2WPkDg,"2001,9/11,9/11-museum,911,911-museum,article,data-visualization,design,fastcodesign.com,fastcodesigncom,jake-barton,local-projects,media-design,museum-exhibit-design,museums,national-september-11-memorial-museum,news,news-events,september-11,shaunacy-ferro,technology,timescape,twistage-db2a546a1abbe,",video,misc
rmnl commented 7 years ago

@jlieb10

I've tested it and I've indeed found a bug. I pushed a fix out with version 2.0.0b9. You can update to that version with:

pip install --upgrade clack-cli==2.0.0b9

Can you config it is working now? Thank you for reporting the issue and for helping me debug it.

jlieb10 commented 7 years ago

@rmnl Seems to be working great- my only issue now is rate limiting but I've submitting a request to have that temporarily disabled on my account. Would be awesome to build in automatically for the batch calls!

In any case, thanks very much for your help.

fairbairn commented 7 years ago

We still have issues, we can't seem to override the output format..

$ clack call -o json /videos/list
Call settings:                                                                  

api type      : ms1
api host      : https://api.jwplatform.com
verify ssl    : False
endpoint      : videos/list
*******************
secret        : ********
output format : py

Never changes from py

rmnl commented 7 years ago

@fairbairn What's your version of clack? clack --version

fairbairn commented 7 years ago

2.0.0b9