Browse Source

detect user profile folder

and improve finding of colors.txt
master
poikilos 9 years ago
committed by Jacob Gustafson
parent
commit
b4246fff2e
  1. 10
      chunkymap-regen.py
  2. 32
      minetestmapper.py

10
chunkymap-regen.py

@ -353,7 +353,7 @@ class MTChunks:
self.refresh_map_enable = True self.refresh_map_enable = True
self.refresh_players_enable = True self.refresh_players_enable = True
self.chunks = {} self.chunks = {}
self.username = "owner" #self.username = "owner"
self.website_root="/var/www/html/minetest" self.website_root="/var/www/html/minetest"
self.world_name = "FCAGameAWorld" self.world_name = "FCAGameAWorld"
self.os_name="linux" self.os_name="linux"
@ -380,7 +380,15 @@ class MTChunks:
self.profiles_path = "/home" self.profiles_path = "/home"
if self.os_name=="windows": if self.os_name=="windows":
self.profiles_path = "C:\\Users" self.profiles_path = "C:\\Users"
if self.username is not None:
self.profile_path = os.path.join(self.profiles_path, self.username) self.profile_path = os.path.join(self.profiles_path, self.username)
else:
if self.os_name=="windows":
self.profiles_path = "C:\\Users"
self.profile_path = os.environ['USERPROFILE']
else:
self.profile_path = os.environ['HOME']
#if (not os.path.isdir(self.profile_path)): #if (not os.path.isdir(self.profile_path)):
# self.profile_path = os.path.join(self.profiles_path, "jgustafson") # self.profile_path = os.path.join(self.profiles_path, "jgustafson")
self.dotminetest_path = os.path.join(self.profile_path,".minetest") self.dotminetest_path = os.path.join(self.profile_path,".minetest")

32
minetestmapper.py

@ -268,8 +268,38 @@ if path[-1:] != "/" and path[-1:] != "\\":
# Load color information for the blocks. # Load color information for the blocks.
colors = {} colors = {}
colors_path = "colors.txt"
os_name="linux"
if (os.path.sep!="/"):
os_name="windows"
profiles_path = "/home"
profile_path = None
if os_name=="windows":
profiles_path = "C:\\Users"
profile_path = os.environ['USERPROFILE']
else:
profile_path = os.environ['HOME']
mt_path = os.path.join( profile_path, "minetest")
mt_util_path = os.path.join( mt_path, "util")
abs_colors_path = os.path.join( mt_util_path, "colors.txt" )
if not os.path.isfile(colors_path):
colors_path = abs_colors_path
if not os.path.isfile(colors_path):
try:
outer_colors_folder_path = os.path.dirname(os.path.dirname(__file__))
outer_colors_path = os.path.join(outer_colors_folder_path, "colors.txt")
if os.path.isfile(outer_colors_path):
colors_path = outer_colors_path
except:
pass
try: try:
f = file("colors.txt") f = file(colors_path)
except IOError: except IOError:
f = file(os.path.join(os.path.dirname(__file__), "colors.txt")) f = file(os.path.join(os.path.dirname(__file__), "colors.txt"))
for line in f: for line in f:

Loading…
Cancel
Save