Last active
February 18, 2018 13:02
-
-
Save continue98/bddee9624f9171724c3a646ee68275b4 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/python | |
import platform, os, shutil, psutil | |
from datetime import datetime | |
class GameMode(object): | |
def __init__(self, gmname): | |
self.gmname = gmname + '.amx' | |
def compile(self): | |
user_platform = platform.system().lower() | |
cpath = ('compiler\%s_compiler\pawncc ' % user_platform) | |
cflags = ['-;+', '-(+', '-d3', '-icompiler\includes sources\main.pwn'] | |
os.system(cpath + ' '.join(cflags)) | |
gm.getDateLastBuild(); | |
print('\a') | |
gm.setDateBuild() | |
gm.getCurrentBuild() | |
os.system('pause') | |
def killProcessCompiler(self): | |
process = filter(lambda p: p.name() == "cmd.exe", psutil.process_iter()) | |
# reinventing a wheel. If running cmd.exe - her will kill :D | |
for i in process: | |
i.kill() | |
def move(self): | |
if os.path.isfile('main.amx'): | |
gmpath = os.getcwd() + '\\gamemodes' | |
if os.path.isfile(gmpath + '\\' + self.gmname): | |
os.remove(gmpath + '\\' + self.gmname) | |
shutil.move('main.amx', gmpath); | |
os.rename(gmpath + '\\' + 'main.amx', gmpath + '\\' + self.gmname) | |
else: | |
shutil.move('main.amx', gmpath); | |
os.rename(gmpath + '\\' + 'main.amx', gmpath + '\\' + self.gmname) | |
def setDateBuild(self): | |
f = open('.last_build_date.log', "w") | |
f.write(datetime.now().strftime("%Y-%m-%d %H:%M:%S")) | |
f.close() | |
def getDateLastBuild(self): | |
if not os.path.exists(".last_build_date.log"): | |
f = open(".last_build_date.log", "a+") | |
else: | |
f = open(".last_build_date.log", "r") | |
print("\nLast build mode:\n", f.read()) | |
f.close(); | |
def getCurrentBuild(self): | |
f = open('.last_build_date.log', "r") | |
print("Current build:\n", f.read() + "\n") | |
f.close() | |
if __name__ == '__main__': | |
gm = GameMode('casino') | |
gm.killProcessCompiler() | |
gm.compile() | |
gm.move() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment