kunyavskiy / polygon-cli

Command-line tool for polygon
MIT License
58 stars 17 forks source link

apiKey: Incorrect signature #19

Closed dj3500 closed 7 years ago

dj3500 commented 7 years ago

Maybe I'm doing something wrong, but I'm getting the following output (under Windows):

C:\algorytmy>polygon-cli add -t TL solution n2_optimized.cpp
Invoking problem.saveSolution 400
apiKey: Incorrect signature

+-----------+--------------+------------------+--------+
| File type | Polygon name |    Local path    | Status |
+-----------+--------------+------------------+--------+
|  solution |     None     | n2_optimized.cpp | Error  |
+-----------+--------------+------------------+--------+

I tried with a different API key pair, but still the same.

kunyavskiy commented 7 years ago

Seams working for me on ubuntu. Unforunatelly I have no Windows to check on it. Probably some problem with end-of-lines in file content in hash calculation. Does methods, which don't involve sending file content works?

dj3500 commented 7 years ago

Oh, the problem was actually non-ASCII characters in my code (comments in Polish). (Not sure which encoding the file was in, probably CP-1250 or ISO-8859-2. Maybe Unicode...) Once the characters are removed from n2_optimized.cpp, it seems to work.

Now I probably have some special characters also in other files, since on polygon-cli update I get:

Invoking problem.files 200
Invoking problem.solutions 200
Updating local file gen_pathlike from gen_pathlike.cpp
Invoking problem.viewFile 200
Updating local file gen_rand from gen_rand.cpp
Invoking problem.viewFile 200
Updating local file validator from validator.cpp
Invoking problem.viewFile 200
Updating local file olymp from olymp.sty
Invoking problem.viewFile 200
Traceback (most recent call last):
  File "C:\Users\3500\Anaconda3\Scripts\polygon-cli-script.py", line 9, in <module>
    load_entry_point('polygon-cli==1.1.0', 'console_scripts', 'polygon-cli')()
  File "C:\Users\3500\Anaconda3\lib\site-packages\polygon_cli-1.1.0-py3.5.egg\polygon_cli\polygon_cli.py", line 36, in main
  File "C:\Users\3500\Anaconda3\lib\site-packages\polygon_cli-1.1.0-py3.5.egg\polygon_cli\actions\update.py", line 59, in <lambda>
  File "C:\Users\3500\Anaconda3\lib\site-packages\polygon_cli-1.1.0-py3.5.egg\polygon_cli\actions\update.py", line 26, in process_update
  File "C:\Users\3500\Anaconda3\lib\site-packages\polygon_cli-1.1.0-py3.5.egg\polygon_cli\utils.py", line 59, in safe_update_file
  File "C:\Users\3500\Anaconda3\lib\site-packages\polygon_cli-1.1.0-py3.5.egg\polygon_cli\utils.py", line 39, in merge_files
  File "C:\Users\3500\Anaconda3\lib\encodings\cp1250.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 in position 2935: character maps to <undefined>
kunyavskiy commented 7 years ago

Seems to be a bug, anyway. I tried to work with solution text as binary data, so encodings should not matter. I'll check it later.

kunyavskiy commented 7 years ago

I talked to polygon authors, they say, they are asuming sources files to be in UTF-8.

dj3500 commented 7 years ago

Thanks. Still, uploading non-UTF-8 files via the Polygon web interface works just fine :)

kunyavskiy commented 7 years ago

Polygon authors said, that for binary files another POST request encoding method should be used. I fixed that. Didn't it solve your problem too?

dj3500 commented 7 years ago

This one seems solved, yes. But something else is not working... I will make a new issue.