diff --git a/README.md b/README.md index 64890f3..7e5b613 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,18 @@ screen -t chunkymapregen python $HOME/chunkymap/generator.py * (2016-03-22) Make a method (in chunkymap.php) to echo the map as an html5 canvas ## Developer Notes: +* minetestinfo.py's Chunk set_from_genresult expects the following lines (such as from minetestmapper.py or minetestmapper-numpy.py): +Result image (w=512 h=3152) will be written to C:\Users\jgustafson\Documents\GitHub\minetest-chunkymap\chunkymap-genresults\Enliven20170213v7\singleimage.png +Drawing image +Saving to: C:\Users\jgustafson\Documents\GitHub\minetest-chunkymap\chunkymap-genresults\Enliven20170213v7\singleimage.png +('PNG Region: ', [-208, 304, -688, 2464]) +('pngMinX: ', '-208') +('pngMaxZ: ', '2464') +('Pixels PerNode: ', 1) +('border: ', 0) + +where PNG Region values are left,right,top,bottom respectively. +where required values are Result image dimensions, and PNG Region or xmin,xmax,zmin,zmax. * Player username privacy: check_players in generator.py intentionally makes up an index and uses that as the filename on the destination, so that ajax can update players without knowing either their id (filename of minetest player file) or display name (listed in the player file) (this way, only usernames can be known if chunkymap.php allows that, or the person is logged in to the server) Because of the feature, generator.py must prevent duplicates based on value of id in the resulting yml files (minetest player filename as id). diff --git a/singleimage.py b/singleimage.py index 7138165..b3af338 100644 --- a/singleimage.py +++ b/singleimage.py @@ -1,5 +1,6 @@ import subprocess import os +#import stat import shutil from minetestinfo import * #python_exe_path is from: @@ -137,11 +138,28 @@ class ChunkymapOfflineRenderer: print(" # (this may take a while...)") if os.path.isfile(tmp_png_path): os.remove(tmp_png_path) + #subprocess.call("touch \""+tmp_png_path+"\"", shell=True) subprocess.call(cmd_string, shell=True) final_png_path = tmp_png_path + www_uid = None + www_gid = None www_chunkymapdata_path = os.path.join(minetestinfo.get_var("www_minetest_path"), "chunkymapdata") www_chunkymapdata_worlds_path = os.path.join(www_chunkymapdata_path, "worlds") www_chunkymapdata_world_path = os.path.join(www_chunkymapdata_worlds_path, self.world_name) + try: + www_stat = os.stat(minetestinfo.get_var("www_minetest_path")) + www_uid = www_stat.st_uid + www_gid = www_stat.st_gid + #import pwd + #www_u_name = pwd.getpwuid(uid)[0] + #www_g_name = pwd.getgrgid(gid)[0] + #import pwd + #import grp + #www_uid = pwd.getpwnam("www_data").pw_uid + #www_gid = grp.getgrnam("nogroup").gr_gid + except: + print("Unable to get stat on www directory \""+minetestinfo.get_var("www_minetest_path")+"\", so will not be able to automatically set owner of result jpg there. Make sure you manually set owner of singleimage.jpg in '"+www_chunkymapdata_world_path+"' to www_data user and group.") + print(" "+str(sys.exc_info())) is_locked = False err_count = 0 @@ -177,6 +195,7 @@ class ChunkymapOfflineRenderer: #this_move_cmd_string = move_cmd_string+" \""+tmp_png_path+"\" to \""+dest_png_path+"\"..." #subprocess.call(this_move_cmd_string, shell=True) shutil.move(tmp_png_path, dest_png_path) #avoids error below according to + # os.rename(tmp_png_path, dest_png_path) # fails with the following output: # Moving temp image from /home/owner/chunkymap/chunkymap-genresults/FCAGameAWorld/singleimage.png to /var/www/html/minetest/chunkymapdata/worlds/FCAGameAWorld/singleimage.png... # Traceback (most recent call last): @@ -206,6 +225,9 @@ class ChunkymapOfflineRenderer: if os.path.isfile(dest_jpg_path): print("jpg image saved to:") print(" "+dest_jpg_path) + if www_gid is not None: + os.chown(dest_jpg_path, www_uid, www_gid) + print("changed owner to same as www folder") os.remove(final_png_path) print("removed temporary file "+final_png_path) else: