100 lines
4.1 KiB
Python
100 lines
4.1 KiB
Python
# Renata Kopecna
|
|
|
|
|
|
#########################################################
|
|
# #
|
|
# Script for easier pushing to git #
|
|
# #
|
|
#########################################################
|
|
|
|
#Bash would work but this is nicer for the user to read
|
|
|
|
|
|
import sys
|
|
import subprocess
|
|
|
|
tmp = subprocess.Popen(["git","branch","--show-current"], cwd = "./", stdout=subprocess.PIPE)
|
|
targetBranch = tmp.communicate()[0].decode("utf-8").strip("\n")
|
|
#print (targetBranch)
|
|
|
|
if (len(sys.argv)!= 3):
|
|
print("Use it only with two arguments! python git.py fileToBePushed commitMessage")
|
|
print("Using " + str(len(sys.argv)) + " arguments")
|
|
exit()
|
|
|
|
toBePushed = sys.argv[1]
|
|
commitMessage = sys.argv[2]
|
|
|
|
class_dict = {
|
|
"generator": "sources/Core/bu2kstarmumu_generator",
|
|
"loader": "sources/Core/bu2kstarmumu_loader",
|
|
"parameters": "sources/Core/bu2kstarmumu_parameters",
|
|
"pdf": "sources/Core/bu2kstarmumu_pdf",
|
|
"plotter": "sources/Core/bu2kstarmumu_plotter",
|
|
"event": "sources/Core/event",
|
|
"folder": "sources/Core/folder",
|
|
"fitter": "sources/Core/fitter",
|
|
"funcs": "sources/Core/funcs",
|
|
"integrals": "sources/Core/integrals",
|
|
"options": "sources/Core/options",
|
|
"toystudy": "sources/Core/toystudy",
|
|
"design": "sources/Helpers/design",
|
|
"helpers": "sources/Helpers/helpers",
|
|
"constants": "sources/Params/constants",
|
|
"parameters.hh": "sources/Params/parameters",
|
|
"parameterscan": "sources/Params/parameterscan",
|
|
"angularcorr": "sources/Run/angularcorr",
|
|
"backgroundfit": "sources/Run/backgroundfit",
|
|
"feldman_cousins": "sources/Run/feldman_cousins",
|
|
"genlvlfit": "sources/Run/genlvlfit",
|
|
"generatetoys": "sources/Run/generatetoys",
|
|
"likelihoodscan": "sources/Run/likelihoodscan",
|
|
"mcfit": "sources/Run/mcfit",
|
|
"mainfit": "sources/Run/mainfit",
|
|
"massfit": "sources/Run/massfit",
|
|
"momfit": "sources/Run/momfit",
|
|
"multifit": "sources/Run/multifit",
|
|
"pulls": "sources/Run/pulls",
|
|
"toysfit": "sources/Run/toysfit",
|
|
"parse": "sources/parse",
|
|
"help": "sources/help",
|
|
"paths": "sources/paths"
|
|
}
|
|
|
|
scripts_dict = {
|
|
"PlotMCfit": "sources/Scripts/PlotMCfit",
|
|
"GenLvlvsMC": "sources/Scripts/GenLvlvsMC",
|
|
"EvaluateToys": "sources/Scripts/EvaluateToys",
|
|
"ReferencePlots": "sources/Scripts/ReferencePlots",
|
|
"ScriptHelpers": "sources/Scripts/ScriptHelpers",
|
|
"RunningScripts": "sources/Scripts/RunningScripts"
|
|
}
|
|
|
|
others_dict ={
|
|
"main": "bu2kstarmumu.cc",
|
|
"plotter.hh": "sources/Core/plotter.hh",
|
|
"values": "sources/Params/values.hh",
|
|
}
|
|
|
|
|
|
mainPath = "/home/lhcb/kopecna/B2KstarMuMu/code/ewp-Bplus2Kstmumu-AngAna/FCNCfitter/"
|
|
if (toBePushed in class_dict):
|
|
add_cc = subprocess.run(["git","add",class_dict.get(toBePushed)+".cc"], cwd = "./", check = False) #Output into console
|
|
add_hh = subprocess.run(["git","add",class_dict.get(toBePushed)+".hh"], cwd = "./", check = False) #Output into console
|
|
elif (toBePushed in others_dict):
|
|
add = subprocess.run(["git","add",others_dict.get(toBePushed)], cwd = "./", check = False) #Output into console
|
|
elif (toBePushed in scripts_dict):
|
|
add_cc = subprocess.run(["git","add",scripts_dict.get(toBePushed)+".cc"], cwd = "./", check = False) #Output into console
|
|
add_hh = subprocess.run(["git","add",scripts_dict.get(toBePushed)+".hh"], cwd = "./", check = False) #Output into console
|
|
else:
|
|
print("Wrong file name! Use any of the following:")
|
|
print (class_dict.keys())
|
|
print (others_dict.keys())
|
|
|
|
add = subprocess.run(["git","commit","-m",commitMessage], cwd = "./", check = True) #Output into console
|
|
add = subprocess.run(["git","push","origin",targetBranch], cwd = "./", check = True) #Output into console
|
|
|
|
print ("\nDone pushing.\n")
|
|
|
|
|