Browse Source

should also work with python3 now

master
poikilos 8 years ago
committed by Jacob Gustafson
parent
commit
6db13576e2
  1. 35
      minetestoffline.py

35
minetestoffline.py

@ -27,18 +27,25 @@ DEBUG_TXT_TIME_FORMAT_STRING="%Y-%m-%d %H:%M:%S"
is_start_now = False is_start_now = False
interactive_enable = False interactive_enable = False
def confirm_min_date(): def confirm_min_date():
global min_date_string global min_date_string
while min_date_string is None: while min_date_string is None:
default_min_date_string = datetime.strftime(datetime.now(), DEBUG_TXT_TIME_FORMAT_STRING) default_min_date_string = datetime.strftime(datetime.now(), DEBUG_TXT_TIME_FORMAT_STRING)
print("") print("")
print("Please enter starting date for player locations and block obtaining to be replayed (only used for inventory recovery feature).") print("Please enter starting date for player locations and block obtaining to be replayed (only used for inventory recovery feature).")
try:
answer = raw_input("Replay Start [YYYY-MM-DD HH-mm-SS format] (blank for "+default_min_date_string+"): ") answer = raw_input("Replay Start [YYYY-MM-DD HH-mm-SS format] (blank for "+default_min_date_string+"): ")
except:
answer = input("Replay Start [YYYY-MM-DD HH-mm-SS format] (blank for "+default_min_date_string+"): ")
if len(answer.strip())>0: if len(answer.strip())>0:
try: try:
min_date = datetime.strptime(answer, DEBUG_TXT_TIME_FORMAT_STRING) min_date = datetime.strptime(answer, DEBUG_TXT_TIME_FORMAT_STRING)
tmp_string = datetime.strftime(min_date, DEBUG_TXT_TIME_FORMAT_STRING) tmp_string = datetime.strftime(min_date, DEBUG_TXT_TIME_FORMAT_STRING)
try:
confirm = raw_input(tmp_string+" ok [Y/n]? ") confirm = raw_input(tmp_string+" ok [Y/n]? ")
except:
confirm = input(tmp_string+" ok [Y/n]? ")
if confirm.strip().lower()=="y" or confirm.strip().lower()=="yes": if confirm.strip().lower()=="y" or confirm.strip().lower()=="yes":
min_date_string = tmp_string min_date_string = tmp_string
except: except:
@ -157,7 +164,10 @@ class MinetestInventoryItem:
is_msg = True is_msg = True
if interactive_enable: if interactive_enable:
if is_msg: if is_msg:
try:
raw_input("Press enter to continue...") raw_input("Press enter to continue...")
except:
input("Press enter to continue...")
return result return result
def set_from_inventory_line(self, line): def set_from_inventory_line(self, line):
@ -191,7 +201,10 @@ class MinetestInventoryItem:
global interactive_enable global interactive_enable
if interactive_enable: if interactive_enable:
if is_warning: if is_warning:
try:
raw_input("Press enter to continue...") raw_input("Press enter to continue...")
except:
input("Press enter to continue...")
else: else:
self.name = "Empty" self.name = "Empty"
@ -241,14 +254,20 @@ class MinetestInventory:
else: else:
print("ERROR in minetestinventory.write_to: items is None") print("ERROR in minetestinventory.write_to: items is None")
if interactive_enable: if interactive_enable:
try:
raw_input("Press enter to continue...") raw_input("Press enter to continue...")
except:
input("Press enter to continue...")
#else: #else:
# print("ERROR in minetestinventory.write_to: width is None") # print("ERROR in minetestinventory.write_to: width is None")
# raw_input("Press enter to continue...") # raw_input("Press enter to continue...")
else: else:
print("ERROR in minetestinventory.write_to: name is None") print("ERROR in minetestinventory.write_to: name is None")
if interactive_enable: if interactive_enable:
try:
raw_input("Press enter to continue...") raw_input("Press enter to continue...")
except:
input("Press enter to continue...")
class MinetestPlayer: class MinetestPlayer:
@ -566,10 +585,21 @@ def convert_storage_to_give_commands_DEPRECATED(this_players_offline_storage_pat
# load_players_offline_storage(this_players_offline_storage_path) # load_players_offline_storage(this_players_offline_storage_path)
while True: while True:
print("") print("")
playerid = None
try:
playerid = raw_input("Minetest Username: ") playerid = raw_input("Minetest Username: ")
except:
playerid = input("Minetest Username: ")
real_name_string = None
try:
real_name_string = raw_input("Real Name: ") real_name_string = raw_input("Real Name: ")
except:
real_name_string = input("Real Name: ")
identifiable_user_description = "first initial + last name + grad year" identifiable_user_description = "first initial + last name + grad year"
try:
identifiable_user_string = raw_input(identifiable_user_description+": ") identifiable_user_string = raw_input(identifiable_user_description+": ")
except:
identifiable_user_string = input(identifiable_user_description+": ")
if len(playerid)>0: if len(playerid)>0:
player_storage_path = os.path.join(this_players_offline_storage_path, playerid) player_storage_path = os.path.join(this_players_offline_storage_path, playerid)
if os.path.isfile(player_storage_path): if os.path.isfile(player_storage_path):
@ -613,7 +643,10 @@ def debug_log_replay_to_offline_player_storage(debug_txt_path, this_players_offl
min_date = datetime.strptime(min_date_string, DEBUG_TXT_TIME_FORMAT_STRING) min_date = datetime.strptime(min_date_string, DEBUG_TXT_TIME_FORMAT_STRING)
print("This will only work if server is offline.") print("This will only work if server is offline.")
print(" (Using min date "+str(min_date)+")") print(" (Using min date "+str(min_date)+")")
try:
raw_input(" press enter to continue, otherwise exit this Window or Ctrl-C to terminate script in GNU/Linux systems...") raw_input(" press enter to continue, otherwise exit this Window or Ctrl-C to terminate script in GNU/Linux systems...")
except:
input(" press enter to continue, otherwise exit this Window or Ctrl-C to terminate script in GNU/Linux systems...")
if players is None: if players is None:
load_players_offline_storage(this_players_offline_storage_path) load_players_offline_storage(this_players_offline_storage_path)
@ -775,6 +808,8 @@ def set_player_names_to_file_names():
##for debug_path in debugs_list: ##for debug_path in debugs_list:
## debug_log_replay_to_offline_player_storage(debug_path, players_offline_storage_path, min_date_string) ## debug_log_replay_to_offline_player_storage(debug_path, players_offline_storage_path, min_date_string)
#debug_log_replay_to_offline_player_storage(debug_txt_path, players_offline_storage_path, min_date_string) #debug_log_replay_to_offline_player_storage(debug_txt_path, players_offline_storage_path, min_date_string)
min_date_string="2016-03-21 00:00:00"
debug_log_replay_to_offline_player_storage("C:\\Users\\jgustafson\\Desktop\\Backup\\fcalocal\\home\\owner\\.minetest\\debug 2017-03-24 stolen panels, cables, battery boxes ONLY.txt", players_offline_storage_path, min_date_string)
def switch_player_file_contents(player1_path, player2_path): def switch_player_file_contents(player1_path, player2_path):
#switches everything except name #switches everything except name

Loading…
Cancel
Save