Skip to content

Commit

Permalink
v2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Skrepysh committed May 4, 2023
1 parent 3a0b2e7 commit 96d9a56
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 43 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
2.Скачайте релиз<br />
3.Распакуйте его в папку<br />
4.В папку mods закиньте все ваши модпаки<br />
5.Откройте settings.txt и следуйте инструкции в нем. (первая строка файла-путь к Майнкрафту,вторая-к папке самой программы)<br /> ВНИМАНИЕ! не используйте кавычки!!!<br />
5.Откройте paths.py и следуйте инструкции в нем. (первая строка файла-путь к Майнкрафту,вторая-к папке самой программы)<br />
6.ПРОФИТ<br />
25 changes: 14 additions & 11 deletions exceptor.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
from worker import worker, verpicker, finish
import os
import time
from filerpy import version_define, dirdefine
from preparator import preparator
from tkinter import messagebox
from filerpy import pySelector
from filerpy import version_define
from preparator import error
programdir = dirdefine("settings.txt", "prog")
minedir = dirdefine("settings.txt", "mine")
from preparator import preparator
from worker import worker, verpicker

programdir = pySelector.prog_preparator()
minedir = pySelector.mine_preparator()


def run(version):
progver = version_define(version)
if preparator("init") == "stopnow":
finish("normal")
else:
pass
while True:
if preparator("init") == "stopnow":
break
else:
pass
try:
os.chdir(f"{programdir}/mods")
vers = [e for e in os.listdir() if os.path.isdir(e)]
Expand All @@ -38,5 +41,5 @@ def run(version):
continue
except Exception:
print("неизвестная ошибка")
time.sleep(3)
messagebox.showerror(title="Ошибка", message="Неизвестная ошибка")
break
38 changes: 26 additions & 12 deletions filerpy.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
import os
from paths import minedir, programdir


def dirdefine(file, type):
if type == "mine":
minedir1 = open(file, "r")
minedir = minedir1.readlines()
minedir1.close()
result = minedir.pop(0).split("\n")
result = result.pop(0).split("\n")
result = result.pop(0)
return result
if type == "prog":
result2 = os.getcwd()
return result2
def version_define(version):
version = str(version)
unknown = "unknown"
if version == "" or version == " ":
return unknown
else:
return version


class prep:
def __init__(self, minedirectory, programdirectory):
self.minedir = minedirectory
self.programdir = programdirectory

def mine_preparator(self):
if self.minedir == "" or not os.path.exists(self.minedir):
self.minedir = "%appdata%/.minecraft"
return self.minedir
else:
minedir.replace('\\', '/')
return self.minedir

def prog_preparator(self):
if self.programdir == "" or not os.path.exists(self.programdir):
self.programdir = os.getcwd()
return self.programdir
else:
return self.programdir


pySelector = prep(minedir, programdir)
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from exceptor import run


program_version = 2.3
program_version = 2.4


run(program_version)

#please, check settings.txt before panic about program is not working
# please, check settings.txt before panic about program is not working
22 changes: 12 additions & 10 deletions preparator.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import os
import time
from filerpy import dirdefine
programdir = dirdefine("settings.txt", "prog")
minedir = dirdefine("settings.txt", "mine")
from filerpy import pySelector
from tkinter import messagebox

programdir = pySelector.prog_preparator()
minedir = pySelector.mine_preparator()


def error():
time.sleep(2)
os.system("cls")


def preparator(type_of_work):
os.chdir(programdir)
if type_of_work == "error":
Expand All @@ -25,8 +29,8 @@ def preparator(type_of_work):
print("Папка создана, повторите попытку")
error()
except FileNotFoundError:
print("Не удалось создать папку!\nПроверьте settings.txt")
time.sleep(2)
messagebox.showerror(title="Ошибка",
message="Не удалось создать папку mods в корне игры!\nПроверьте paths.py")
return "stopnow"
if not os.path.exists(f"{programdir}/mods"):
print("Отсутствует хранилище модпаков:-(")
Expand All @@ -39,8 +43,7 @@ def preparator(type_of_work):
time.sleep(2)
error()
else:
print("Какой-то файл/папка не найден.\nПроверьте settings.txt")
time.sleep(2)
print("hfdsjkhfljka")
return "stopnow"
if type_of_work == "init":
if not os.path.exists(f"{programdir}/backup"):
Expand All @@ -57,8 +60,8 @@ def preparator(type_of_work):
print("Папка создана, повторите попытку")
error()
except FileNotFoundError:
print("Не удалось создать папку!\nПроверьте settings.txt")
time.sleep(2)
messagebox.showerror(title="Ошибка",
message="Не удалось создать папку mods в корне игры!\nПроверьте paths.py")
return "stopnow"
if not os.path.exists(f"{programdir}/mods"):
print("Отсутствует хранилище модпаков:-(")
Expand All @@ -70,4 +73,3 @@ def preparator(type_of_work):
print("В корне программы создана папка mods, поместите туда свои модпаки")
time.sleep(2)
error()

3 changes: 0 additions & 3 deletions settings.txt

This file was deleted.

10 changes: 6 additions & 4 deletions worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import shutil
import time
from pathlib import Path
from filerpy import dirdefine
programdir = str(dirdefine("settings.txt", "prog"))
minedir = str(dirdefine("settings.txt", "mine"))

from filerpy import pySelector
programdir = pySelector.prog_preparator()
minedir = pySelector.mine_preparator()


def finish(type):
Expand All @@ -21,6 +20,7 @@ def finish(type):
while True:
break


def verpicker(progver, vers):
print("Привет!")
print("Версия программы: " + progver)
Expand Down Expand Up @@ -53,11 +53,13 @@ def verpicker(progver, vers):
print("Выбрана версия " + a)
return a


def worker(version):
if version == "restok":
finish("normal")
elif version == "stop":
finish("error")
exit()
elif version == "stop_soft":
finish("normal")
else:
Expand Down

0 comments on commit 96d9a56

Please sign in to comment.