Jump to content

Backup Script For Metin2 Source Code


Recommended Posts

  • Former Staff

Backup your source code with this script ... my source code include(client, server, tools, extern) which there size exactly = 4.69 GB (5,044,632,548 bytes)

after compressing size of archive = 32.5 MB (34,117,184 bytes)

but you must first install WinRar archiver  which you can download it from here

http://filehippo.com/download_winrar_32/

or from here

http://www.softpedia.com/get/Compression-tools/WinRAR.shtml#download

import os , shutil, sys
from os import path , system
ignored = [".sdf",".opensdf", "",".pch", ".vcproj", ".tlog", ".log", ".exe", ".Release",
".obj", ".sbr", ".bak", ".ipch", ".pdb", ".cod", ".lastbuildstate", ".bsc" ,".res", ".idb"
,".cache", ".htm", ".cmd"]
ignoreddirs = ["MfcDebug", "Release", "Debug","ipch","bin","obj", "Distribute", ".tlog", ".*cmd"]
bCMD = "temp.cmd"
i = 0
def comperess_writer(foldername):
	if not os.listdir(foldername): 
		print("Error: %s folder is empty \nsystem will close the script now"%(foldername))
		system("pause")# this is an optinal command if you want to see what is going on
		return
	x = open(bCMD, 'w')
	x.write('set path="C:\Program Files\WinRAR\";%path% c:/Program Files/WinRAR/\n')
	x.write('Rar.exe a -ac -r -m5 -esh -mc12t -ep1 ')
	i = 0
	while i <= (len(ignoreddirs) - 1):
		x.write(' -x\*%s\*'%(ignoreddirs[i]))
		i += 1
	x.write(" \"Backup\" ")
	chkdict = {}
	setdef = chkdict.setdefault
	for root, dirs, files in os.walk(foldername):
		for file in files:
			ext = path.splitext(file)[1]
			if ext in chkdict or ext in ignored:
				continue
			print("%s" % setdef(ext,ext))
			x.write(foldername + "\*%s " % setdef(ext,ext))
	x.write(" *makefile *Depend *readme *tags\npause")
	x.close()
	type = yes_no("Do you want to backup now?", "yes")
	if type == True:
		comperess()
	exit()
def comperess():
	os.system(bCMD)
	os.remove(bCMD)
	
def yes_no(question, default="yes"):
	valid = {"yes": True, "y": True, "ye": True, "no": False, "n": False}
	if default is None:
		prompt = " [y/n] "
	elif default == "yes":
		prompt = " [Y/n] "
	elif default == "no":
		prompt = " [y/N] "
	else:
		raise ValueError("invalid default answer: '%s'" % default)

	
	sys.stdout.write(question + prompt)
	choice = raw_input().lower()
	if default is not None and choice == '':
		return valid[default]
	if choice in valid:
		return valid[choice]
	else:
		sys.stdout.write("Please respond with 'yes' or 'no' ", "(or 'y' or 'n').\n")

def main():
	global i
	if i == 0:
		print ("Hello This is Auto Backup program\nfor Metin2 C++ source code")
		print ("type the number of the command you want to execute")
	print ("1:Comperess\n2:Exit")
	type = raw_input("Type Number:")
	type = int(type)
	if type == 1:
		folder = raw_input("Folder Name:")
		if not os.path.isdir(folder):
			exit()
		comperess_writer(folder)
	if type == 2:
		exit()
	else:
		i +=1
		os.system("cls")
		print ("Please Type 1 or 2")
		main()
		
main()

#updated --> fixed the archiving problem "archiving very folder in the current folder"

#updated --> more compressing plus cleaning attributes after finishing

  • Metin2 Dev 3
  • Good 1
  • Love 4
Link to comment
Share on other sites

  • 1 month later...

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.