From 0b70c04468492b957c1fb321b7e09be437e5bba2 Mon Sep 17 00:00:00 2001 From: jonpas Date: Fri, 22 May 2015 20:12:41 +0200 Subject: [PATCH 1/5] Added maindir, projectdir and cba variables --- tools/setup.py | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/tools/setup.py b/tools/setup.py index 1b9ab119d9..16a5a045c7 100644 --- a/tools/setup.py +++ b/tools/setup.py @@ -12,6 +12,11 @@ import platform import subprocess import winreg +######## GLOBALS ######### +maindir = "z" +projectdir = "ace" +cba = "P:\\x\\cba" +########################## def main(): print(""" @@ -60,26 +65,26 @@ def main(): print("\n# Creating links ...") - if os.path.exists("P:\\z\\ace"): + if os.path.exists("P:\\{}\\{}".format(maindir,projectdir)): print("Link on P: already exists. Please finish the setup manually.") return 4 - if os.path.exists(os.path.join(armapath, "z", "ace")): + if os.path.exists(os.path.join(armapath, maindir, projectdir)): print("Link in Arma directory already exists. Please finish the setup manually.") return 5 try: - if not os.path.exists("P:\\z"): - os.mkdir("P:\\z") - if not os.path.exists(os.path.join(armapath, "z")): - os.mkdir(os.path.join(armapath, "z")) + if not os.path.exists("P:\\" + maindir): + os.mkdir("P:\\" + maindir) + if not os.path.exists(os.path.join(armapath, maindir)): + os.mkdir(os.path.join(armapath, maindir)) if platform.win32_ver()[0] == "7": - subprocess.call(["cmd", "/c", "mklink", "/D", "P:\\z\\ace", projectpath]) - subprocess.call(["cmd", "/c", "mklink", "/D", os.path.join(armapath, "z", "ace"), projectpath]) + subprocess.call(["cmd", "/c", "mklink", "/D", "P:\\{}\\{}".format(maindir,projectdir), projectpath]) + subprocess.call(["cmd", "/c", "mklink", "/D", os.path.join(armapath, maindir, projectdir), projectpath]) else: - subprocess.call(["cmd", "/c", "mklink", "/D", "/J", "P:\\z\\ace", projectpath]) - subprocess.call(["cmd", "/c", "mklink", "/D", "/J", os.path.join(armapath, "z", "ace"), projectpath]) + subprocess.call(["cmd", "/c", "mklink", "/D", "/J", "P:\\{}\\{}".format(maindir,projectdir), projectpath]) + subprocess.call(["cmd", "/c", "mklink", "/D", "/J", os.path.join(armapath, maindir, projectdir), projectpath]) except: raise print("Something went wrong during the link creation. Please finish the setup manually.") @@ -90,18 +95,18 @@ def main(): print("\n# Copying required CBA includes ...") - if os.path.exists("P:\\x\\cba"): - print("P:\\x\\cba already exists, skipping.") + if os.path.exists(cba): + print(cba + " already exists, skipping.") return -1 try: - shutil.copytree(os.path.join(projectpath, "tools", "cba"), "P:\\x\\cba") + shutil.copytree(os.path.join(projectpath, "tools", "cba"), cba) except: raise - print("Something went wrong while copying CBA includes. Please copy tools\\cba to P:\\x\\cba manually.") + print("Something went wrong while copying CBA includes. Please copy tools\\cba to {} manually.".format(cba)) return 7 - print("# CBA includes copied successfully to P:\\x\\cba.") + print("# CBA includes copied successfully to {}.".format(cba)) return 0 From cc70d6808c9cd7d5f07116b8dea84b5736cc03a4 Mon Sep 17 00:00:00 2001 From: jonpas Date: Fri, 22 May 2015 20:20:47 +0200 Subject: [PATCH 2/5] Added fulldir and cba variables to initial ouput text --- tools/setup.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/setup.py b/tools/setup.py index 16a5a045c7..6a2132f54c 100644 --- a/tools/setup.py +++ b/tools/setup.py @@ -19,6 +19,7 @@ cba = "P:\\x\\cba" ########################## def main(): + fulldir = maindir + "\\" + projectdir print(""" ###################################### # ACE3 Development Environment Setup # @@ -33,10 +34,10 @@ def main(): If you have not done those things yet, please abort this script in the next step and do so first. This script will create two hard links on your system, both pointing to your ACE3 project folder: - [Arma 3 installation directory]\\z\\ace => ACE3 project folder - P:\\z\\ace => ACE3 project folder + [Arma 3 installation directory]\\{} => ACE3 project folder + P:\\{} => ACE3 project folder - It will also copy the required CBA includes to P:\\x\\cba, if you do not have the CBA source code already.""") + It will also copy the required CBA includes to {}, if you do not have the CBA source code already.""".format(fulldir,fulldir,cba)) print("\n") try: From 7cf64c7a521d61bc5df91f68dd1ef91b68368642 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sat, 23 May 2015 02:34:55 +0200 Subject: [PATCH 3/5] New-school .format --- tools/setup.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tools/setup.py b/tools/setup.py index 6a2132f54c..d6672f09b3 100644 --- a/tools/setup.py +++ b/tools/setup.py @@ -4,7 +4,6 @@ # ACE3 Setup Script # ####################### - import os import sys import shutil @@ -19,7 +18,7 @@ cba = "P:\\x\\cba" ########################## def main(): - fulldir = maindir + "\\" + projectdir + fulldir = "{}\\{}".format(maindir,projectdir) print(""" ###################################### # ACE3 Development Environment Setup # @@ -75,8 +74,8 @@ def main(): return 5 try: - if not os.path.exists("P:\\" + maindir): - os.mkdir("P:\\" + maindir) + if not os.path.exists("P:\\{}".format(maindir)): + os.mkdir("P:\\{}".format(maindir)) if not os.path.exists(os.path.join(armapath, maindir)): os.mkdir(os.path.join(armapath, maindir)) @@ -97,7 +96,7 @@ def main(): print("\n# Copying required CBA includes ...") if os.path.exists(cba): - print(cba + " already exists, skipping.") + print("{} already exists, skipping.".format(cba)) return -1 try: From 88c57780fc61013d65ec9ccd835781be6da5cdd6 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 24 May 2015 22:09:28 +0200 Subject: [PATCH 4/5] Capitalized globals --- tools/setup.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tools/setup.py b/tools/setup.py index d6672f09b3..4d71ed75a2 100644 --- a/tools/setup.py +++ b/tools/setup.py @@ -12,13 +12,13 @@ import subprocess import winreg ######## GLOBALS ######### -maindir = "z" -projectdir = "ace" -cba = "P:\\x\\cba" +MAINDIR = "z" +PROJECTDIR = "ace" +CBA = "P:\\x\\cba" ########################## def main(): - fulldir = "{}\\{}".format(maindir,projectdir) + fulldir = "{}\\{}".format(MAINDIR,PROJECTDIR) print(""" ###################################### # ACE3 Development Environment Setup # @@ -36,7 +36,7 @@ def main(): [Arma 3 installation directory]\\{} => ACE3 project folder P:\\{} => ACE3 project folder - It will also copy the required CBA includes to {}, if you do not have the CBA source code already.""".format(fulldir,fulldir,cba)) + It will also copy the required CBA includes to {}, if you do not have the CBA source code already.""".format(fulldir,fulldir,CBA)) print("\n") try: @@ -65,26 +65,26 @@ def main(): print("\n# Creating links ...") - if os.path.exists("P:\\{}\\{}".format(maindir,projectdir)): + if os.path.exists("P:\\{}\\{}".format(MAINDIR,PROJECTDIR)): print("Link on P: already exists. Please finish the setup manually.") return 4 - if os.path.exists(os.path.join(armapath, maindir, projectdir)): + if os.path.exists(os.path.join(armapath, MAINDIR, PROJECTDIR)): print("Link in Arma directory already exists. Please finish the setup manually.") return 5 try: - if not os.path.exists("P:\\{}".format(maindir)): - os.mkdir("P:\\{}".format(maindir)) - if not os.path.exists(os.path.join(armapath, maindir)): - os.mkdir(os.path.join(armapath, maindir)) + if not os.path.exists("P:\\{}".format(MAINDIR)): + os.mkdir("P:\\{}".format(MAINDIR)) + if not os.path.exists(os.path.join(armapath, MAINDIR)): + os.mkdir(os.path.join(armapath, MAINDIR)) if platform.win32_ver()[0] == "7": - subprocess.call(["cmd", "/c", "mklink", "/D", "P:\\{}\\{}".format(maindir,projectdir), projectpath]) - subprocess.call(["cmd", "/c", "mklink", "/D", os.path.join(armapath, maindir, projectdir), projectpath]) + subprocess.call(["cmd", "/c", "mklink", "/D", "P:\\{}\\{}".format(MAINDIR,PROJECTDIR), projectpath]) + subprocess.call(["cmd", "/c", "mklink", "/D", os.path.join(armapath, MAINDIR, PROJECTDIR), projectpath]) else: - subprocess.call(["cmd", "/c", "mklink", "/D", "/J", "P:\\{}\\{}".format(maindir,projectdir), projectpath]) - subprocess.call(["cmd", "/c", "mklink", "/D", "/J", os.path.join(armapath, maindir, projectdir), projectpath]) + subprocess.call(["cmd", "/c", "mklink", "/D", "/J", "P:\\{}\\{}".format(MAINDIR,PROJECTDIR), projectpath]) + subprocess.call(["cmd", "/c", "mklink", "/D", "/J", os.path.join(armapath, MAINDIR, PROJECTDIR), projectpath]) except: raise print("Something went wrong during the link creation. Please finish the setup manually.") @@ -95,18 +95,18 @@ def main(): print("\n# Copying required CBA includes ...") - if os.path.exists(cba): - print("{} already exists, skipping.".format(cba)) + if os.path.exists(CBA): + print("{} already exists, skipping.".format(CBA)) return -1 try: - shutil.copytree(os.path.join(projectpath, "tools", "cba"), cba) + shutil.copytree(os.path.join(projectpath, "tools", "cba"), CBA) except: raise - print("Something went wrong while copying CBA includes. Please copy tools\\cba to {} manually.".format(cba)) + print("Something went wrong while copying CBA includes. Please copy tools\\cba to {} manually.".format(CBA)) return 7 - print("# CBA includes copied successfully to {}.".format(cba)) + print("# CBA includes copied successfully to {}.".format(CBA)) return 0 From 0771ab21b6c460e4718feb26cf8e077bb45d2580 Mon Sep 17 00:00:00 2001 From: jonpas Date: Sun, 24 May 2015 22:12:56 +0200 Subject: [PATCH 5/5] Capitalized previously missed global --- tools/setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/setup.py b/tools/setup.py index 4d71ed75a2..62925a6066 100644 --- a/tools/setup.py +++ b/tools/setup.py @@ -18,7 +18,7 @@ CBA = "P:\\x\\cba" ########################## def main(): - fulldir = "{}\\{}".format(MAINDIR,PROJECTDIR) + FULLDIR = "{}\\{}".format(MAINDIR,PROJECTDIR) print(""" ###################################### # ACE3 Development Environment Setup # @@ -36,7 +36,7 @@ def main(): [Arma 3 installation directory]\\{} => ACE3 project folder P:\\{} => ACE3 project folder - It will also copy the required CBA includes to {}, if you do not have the CBA source code already.""".format(fulldir,fulldir,CBA)) + It will also copy the required CBA includes to {}, if you do not have the CBA source code already.""".format(FULLDIR,FULLDIR,CBA)) print("\n") try: