-
Notifications
You must be signed in to change notification settings - Fork 0
/
7days_mod_installer.py
105 lines (80 loc) · 2.93 KB
/
7days_mod_installer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import os
import sys
import zipfile
import urllib
import urllib.request
import colorama
from colorama import Fore, Back, Style
import pyunpack
import progressbar
import shutil
def enterpath():
global home
print("BITTE 7Days2Die Pfad eingeben!")
print("z.b C:/Steam/steamapps/common/7 Days To Die")
home=input("PFAD: ")
print()
if os.path.exists(home+"/7DaysToDie.exe"):
os.system("cls")
installMods()
else:
print("---")
print("Der Pfad stimmt nicht! // 7Days nicht gefunden!")
print("---")
print()
enterpath()
def installMods():
global home
global pbar
pbar = None
def show_progress(block_num, block_size, total_size):
global pbar
if pbar is None:
pbar = progressbar.ProgressBar(maxval=total_size)
total_size = total_size
downloaded = block_num * block_size
if downloaded < total_size:
pbar.update(downloaded)
else:
pbar.finish()
pbar = None
colorama.init()
print("7Days2Die wurde gefunden!")
print("---")
print("Grüße von 1Day2Die")
input("Drücke -Enter- um das Modpack zu installieren")
#home = os.path.join("D:\\", "Steam", "steamapps", "common", "7 Days To Die", "")
n = 0
old_Mods_folder_name = "old_Mods" + str(n)
while os.path.exists(os.path.join(home, str(old_Mods_folder_name))):
n += 1
old_Mods_folder_name = "old_Mods" + str(n)
#print(n)
if os.path.exists(os.path.join(home, "Mods")):
os.rename(os.path.join(home, "Mods"), os.path.join(home, str(old_Mods_folder_name)))
os.mkdir(os.path.join(home, "Mods"))
try:
print(Fore.MAGENTA + "Downloading Modpack")
urllib.request.urlretrieve("http://downloads.hafuga.de/7days/Mods.zip", os.path.join(home, "Mods", "") + "Mods.zip", show_progress)
except Exception as e: print(e)
try:
pyunpack.Archive(os.path.join(home, "Mods", "") + "Mods.zip").extractall(os.path.join(home, "Mods"))
except Exception as e: print(e)
os.remove(os.path.join(home, "Mods", "") + "Mods.zip")
shutil.rmtree(os.path.join(home, str(old_Mods_folder_name)))
print("")
print(Fore.GREEN + "Mods sind Installiert!")
print("")
print("")
print(Back.GREEN, Fore.BLACK + "Den Server erreichst du unter:")
print("193.26.159.126:26900")
print(Style.RESET_ALL)
input("Das Fenster kann geschlossen werden")
else:
os.mkdir(os.path.join(home, "Mods"))
print(Fore.RED + "7Days2Die Mods Ordner nicht gefunden unter " + home)
print()
print(Fore.GREEN + "Mods ordner wurde erstellt. Bitte ENTER drücken oder Programm neustarten")
installMods()
print(Style.RESET_ALL)
enterpath()