AliFlux / MapTilesDownloader

A super easy to use map tiles downloader built using Python
MIT License
423 stars 122 forks source link

No Downloads and Errors in code window #10

Open Davierooker opened 3 years ago

Davierooker commented 3 years ago

Running Windows 10, can get the app loaded and select area but no download. Exception happened during processing of request from ('127.0.0.1', 11709) Traceback (most recent call last): File "C:\Users\cwilson.KORBEN\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 639, in process_request_thread self.finish_request(request, client_address) File "C:\Users\cwilson.KORBEN\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 361, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\Users\cwilson.KORBEN\AppData\Local\Programs\Python\Python36\lib\socketserver.py", line 696, in init self.handle() File "C:\Users\cwilson.KORBEN\AppData\Local\Programs\Python\Python36\lib\http\server.py", line 418, in handle self.handle_one_request() File "C:\Users\cwilson.KORBEN\AppData\Local\Programs\Python\Python36\lib\http\server.py", line 406, in handle_one_request method() File "server.py", line 153, in do_POST self.writerByType(outputType).addMetadata(lock, os.path.join("output", outputDirectory), filePath, outputFile, "Map Tiles Downloader via AliFlux", "png", boundsArray, centerArray, minZoom, maxZoom, "mercator", 256 * outputScale) AttributeError: 'NoneType' object has no attribute 'addMetadata'

apaleja commented 3 years ago

I am also getting this same error. did you find any solution ?

Dawson-Jiang commented 3 years ago

you can print outputType value for check reason

RussellTaylor83 commented 3 years ago

I have this problem under Ubuntu and not Windows. In server.py, line 133 you'll see

outputDirectory = str(postvars['outputDirectory'][0])

If you print out the value with the following you get different values under Windows and Ubuntu

print("postvars['outputDirectory'][0]: " + str(postvars['outputDirectory'][0]))

Under ubuntu this gives b'{timestamp}' and under windows it gives the correct {timestamp}

I'm not a Python guy but it seems str conversions are handled differently under each OS. On a quick Google search it's something to do with being a byte array and not understanding the character encoding when using str(). Anyway in Ubuntu I swapped out that block of code for this

elif parts.path == '/start-download':
    outputType = str(postvars['outputType'][0], 'utf-8')
    outputScale = int(postvars['outputScale'][0])
    outputDirectory = str(postvars['outputDirectory'][0], 'utf-8')
    outputFile = str(postvars['outputFile'][0], 'utf-8')
    minZoom = int(postvars['minZoom'][0])
    maxZoom = int(postvars['maxZoom'][0])
    timestamp = int(postvars['timestamp'][0])
    bounds = str(postvars['bounds'][0], 'utf-8')
    boundsArray = map(float, bounds.split(","))
    center = str(postvars['center'][0], 'utf-8')
    centerArray = map(float, center.split(","))

Note all str functions having the second argument passed in. Anyway there is probably a correct way to fix this, but this got it running for me for now.

If I get time to figure it out properly I'll post back.

AliFlux commented 3 years ago

I'm currently porting the code to Electron since there are too many python issues including version confusions and performance hits. The v2 will be significantly faster and easier to run