-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,373 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
{ | ||
"online_count": 0, | ||
"players": {}, | ||
"server_status": "Shutdown" | ||
"online_count": 2, | ||
"players": { | ||
"Hr3born[LV]": { | ||
"status": "Online,Spawned", | ||
"pltfm_id": "Steam_76561197995381320" | ||
}, | ||
"boqsc": { | ||
"status": "Online,Joining", | ||
"pltfm_id": "Steam_76561198072601792" | ||
} | ||
}, | ||
"server_status": "Online" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
59 changes: 59 additions & 0 deletions
59
...r/Webserver-testing/Webserver_prev/Webserver_FindNextHordeNightTime_inside_logs_folder.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Webserver_FindNextHordeNightTime_inside_logs_folder.py | ||
|
||
import os | ||
import glob | ||
from datetime import datetime | ||
import re | ||
|
||
def find_last_bloodmoon_setday(): | ||
# Get the directory of the current script | ||
script_dir = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
# Directory containing the log files relative to the script's directory | ||
log_directory = os.path.join(script_dir, '../7DaysToDie_Data') | ||
|
||
# Temporary | Optional | Remove this later | ||
# Override log directory with default 7DTD Path on Windows. | ||
#log_directory = "C:/Program Files (x86)/Steam/steamapps/common/7 Days To Die/7DaysToDie_Data" | ||
|
||
# Define the pattern to match files | ||
file_pattern = 'output_log__*.txt' | ||
|
||
# Get a list of all files matching the pattern | ||
log_files = glob.glob(os.path.join(log_directory, file_pattern)) | ||
|
||
# Function to extract timestamp from filename | ||
def extract_timestamp(filename): | ||
timestamp_str = filename.split('__')[1] | ||
return datetime.strptime(filename.split('__')[1]+ "__" +filename.split('__')[2], '%Y-%m-%d__%H-%M-%S.txt') | ||
|
||
# Function to extract day number from line | ||
def extract_day_number(line): | ||
match = re.search(r'day (\d+)', line) | ||
if match: | ||
return int(match.group(1)) | ||
return None | ||
|
||
# Sort the files by timestamp (newest first) | ||
log_files.sort(key=lambda x: extract_timestamp(x), reverse=True) | ||
|
||
if log_files: | ||
latest_file = log_files[0] | ||
print("Latest file:", latest_file) | ||
|
||
# Open the latest log file | ||
with open(latest_file, 'r') as file: | ||
# Read the lines of the file in reverse order | ||
lines = reversed(file.readlines()) | ||
# Search for the last occurrence of the line containing the information | ||
for line in lines: | ||
if "BloodMoon SetDay" in line: | ||
day_number = extract_day_number(line) | ||
if day_number: | ||
return day_number | ||
else: | ||
print("Day number not found in the line.") | ||
break | ||
else: | ||
print("No log files found.") | ||
return None |
2 changes: 2 additions & 0 deletions
2
...server-testing/Webserver_prev/Webserver_FindNextHordeNightTime_inside_logs_folder_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import Webserver_FindNextHordeNightTime_inside_logs_folder | ||
Webserver_FindNextHordeNightTime_inside_logs_folder.find_last_bloodmoon_setday() |
28 changes: 28 additions & 0 deletions
28
webserver/Webserver-testing/Webserver_prev/Webserver_Get_Latest_Game_Server_Log_File.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
import os | ||
import glob | ||
from datetime import datetime | ||
import re | ||
|
||
def get_latest_game_server_log_file_name(): | ||
script_dir = os.path.dirname(os.path.abspath(__file__)) | ||
log_directory = os.path.join(script_dir, '../7DaysToDie_Data') | ||
|
||
# Temporary | Optional | Remove this later | ||
# Override log directory with default 7DTD Path on Windows. | ||
#log_directory = "C:/Program Files (x86)/Steam/steamapps/common/7 Days To Die/7DaysToDie_Data" | ||
|
||
file_pattern = 'output_log__*.txt' | ||
log_files = glob.glob(os.path.join(log_directory, file_pattern)) | ||
|
||
# Function to extract timestamp from filename | ||
def extract_timestamp(filename): | ||
timestamp_str = filename.split('__')[1] | ||
return datetime.strptime(filename.split('__')[1]+ "__" +filename.split('__')[2], '%Y-%m-%d__%H-%M-%S.txt') | ||
log_files.sort(key=lambda x: extract_timestamp(x), reverse=True) | ||
if log_files: | ||
latest_file = log_files[0] | ||
print("Latest file:", latest_file) | ||
return latest_file | ||
|
||
|
Oops, something went wrong.