[DEV] add commit and push, better armgument methode, and better help
This commit is contained in:
parent
bc82c533f1
commit
0f47c841fd
@ -54,36 +54,33 @@ def init():
|
|||||||
|
|
||||||
is_init = True
|
is_init = True
|
||||||
|
|
||||||
|
# initialize the system ...
|
||||||
myArgs = arguments.islandArg()
|
init()
|
||||||
myArgs.add_section("option", "Can be set one time in all case")
|
|
||||||
myArgs.add("h", "help", desc="Display this help")
|
|
||||||
myArgs.add("v", "verbose", list=[["0","None"],["1","error"],["2","warning"],["3","info"],["4","debug"],["5","verbose"],["6","extreme_verbose"]], desc="display debug level (verbose) default =2")
|
|
||||||
myArgs.add("c", "color", desc="Display message in color")
|
|
||||||
# for init only
|
|
||||||
#myArgs.add("h", "help", desc="Help of this action")
|
|
||||||
myArgs.add("b", "branch", haveParam=True, desc="Select branch to display")
|
|
||||||
myArgs.add("m", "manifest", haveParam=True, desc="Name of the manifest")
|
|
||||||
myArgs.add("N", "no-fetch-manifest", haveParam=False, desc="Disable the fetch of the manifest")
|
|
||||||
"""
|
|
||||||
myArgs.add("j", "jobs", haveParam=True, desc="Specifies the number of jobs (commands) to run simultaneously")
|
|
||||||
myArgs.add("d", "depth", haveParam=True, desc="Depth to clone all the repository")
|
|
||||||
|
|
||||||
"""
|
|
||||||
localArgument = myArgs.parse()
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
debug.verbose("List of actions: " + str(actions.get_list_of_action()))
|
||||||
display the help of this makefile
|
|
||||||
"""
|
my_args = arguments.islandArg()
|
||||||
|
my_args.add_section("option", "Can be set one time in all case")
|
||||||
|
my_args.add("h", "help", desc="Display this help")
|
||||||
|
my_args.add("v", "verbose", list=[["0","None"],["1","error"],["2","warning"],["3","info"],["4","debug"],["5","verbose"],["6","extreme_verbose"]], desc="display debug level (verbose) default =2")
|
||||||
|
my_args.add("c", "color", desc="Display message in color")
|
||||||
|
my_args.add("n", "no-fetch-manifest", haveParam=False, desc="Disable the fetch of the manifest")
|
||||||
|
my_args.set_stop_at(actions.get_list_of_action())
|
||||||
|
local_argument = my_args.parse()
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Display the help of this makefile.
|
||||||
|
##
|
||||||
def usage():
|
def usage():
|
||||||
color = debug.get_color_set()
|
color = debug.get_color_set()
|
||||||
# generic argument displayed :
|
# generic argument displayed :
|
||||||
myArgs.display()
|
my_args.display()
|
||||||
print(" Action availlable" )
|
print(" Action availlable" )
|
||||||
list_actions = actions.get_list_of_action();
|
list_actions = actions.get_list_of_action();
|
||||||
for elem in list_actions:
|
for elem in list_actions:
|
||||||
print(" " + color['green'] + elem + color['default'])
|
print(" " + color['green'] + elem + color['default'])
|
||||||
|
print(" " + actions.get_action_help(elem))
|
||||||
"""
|
"""
|
||||||
print(" " + color['green'] + "init" + color['default'])
|
print(" " + color['green'] + "init" + color['default'])
|
||||||
print(" initialize a 'island' interface with a manifest in a git ")
|
print(" initialize a 'island' interface with a manifest in a git ")
|
||||||
@ -191,15 +188,12 @@ if os.path.isfile(config_file) == True:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# parse default unique argument:
|
# parse default unique argument:
|
||||||
for argument in localArgument:
|
for argument in local_argument:
|
||||||
parseGenericArg(argument, True)
|
parseGenericArg(argument, True)
|
||||||
|
|
||||||
# initialize the system ...
|
|
||||||
init()
|
|
||||||
|
|
||||||
# remove all generic arguments:
|
# remove all generic arguments:
|
||||||
new_argument_list = []
|
new_argument_list = []
|
||||||
for argument in localArgument:
|
for argument in local_argument:
|
||||||
if parseGenericArg(argument, False) == True:
|
if parseGenericArg(argument, False) == True:
|
||||||
continue
|
continue
|
||||||
new_argument_list.append(argument)
|
new_argument_list.append(argument)
|
||||||
@ -230,7 +224,7 @@ if action_to_do != "init" \
|
|||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
|
|
||||||
actions.execute(action_to_do, new_argument_list)
|
actions.execute(action_to_do, my_args.get_last_parsed()+1)
|
||||||
|
|
||||||
# stop all started threads;
|
# stop all started threads;
|
||||||
#multiprocess.un_init()
|
#multiprocess.un_init()
|
||||||
|
@ -13,6 +13,7 @@ from . import debug
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from . import env
|
from . import env
|
||||||
|
from . import arguments
|
||||||
|
|
||||||
list_actions = []
|
list_actions = []
|
||||||
|
|
||||||
@ -61,25 +62,58 @@ def get_desc(action_name):
|
|||||||
sys.path.append(os.path.dirname(elem["path"]))
|
sys.path.append(os.path.dirname(elem["path"]))
|
||||||
the_action = __import__(__base_action_name + action_name)
|
the_action = __import__(__base_action_name + action_name)
|
||||||
if "get_desc" not in dir(the_action):
|
if "get_desc" not in dir(the_action):
|
||||||
debug.error("execute is not implmented for this action ... '" + str(action_name) + "'")
|
return ""
|
||||||
return None
|
|
||||||
return the_action.get_desc()
|
return the_action.get_desc()
|
||||||
return None
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def execute(action_name, argument_list):
|
def usage(arguments, action_name):
|
||||||
|
color = debug.get_color_set()
|
||||||
|
# generic argument displayed for specific action:
|
||||||
|
print("Specific argument for the command: '" + action_name + "'" )
|
||||||
|
print(" " + get_desc(action_name))
|
||||||
|
arguments.display(action_name)
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
def execute(action_name, argument_start_id):
|
||||||
global list_actions;
|
global list_actions;
|
||||||
# TODO: Move here the check if action is availlable
|
# TODO: Move here the check if action is availlable
|
||||||
|
|
||||||
for elem in list_actions:
|
for elem in list_actions:
|
||||||
if elem["name"] == action_name:
|
if elem["name"] != action_name:
|
||||||
debug.info("action: " + str(elem));
|
continue
|
||||||
# finish the parsing
|
debug.info("action: " + str(elem));
|
||||||
sys.path.append(os.path.dirname(elem["path"]))
|
# finish the parsing
|
||||||
the_action = __import__(__base_action_name + action_name)
|
sys.path.append(os.path.dirname(elem["path"]))
|
||||||
if "execute" not in dir(the_action):
|
the_action = __import__(__base_action_name + action_name)
|
||||||
debug.error("execute is not implmented for this action ... '" + str(action_name) + "'")
|
my_under_args_parser = arguments.islandArg()
|
||||||
|
my_under_args_parser.add("h", "help", desc="Help of this action")
|
||||||
|
if "add_specific_arguments" in dir(the_action):
|
||||||
|
the_action.add_specific_arguments(my_under_args_parser, elem["name"])
|
||||||
|
my_under_args = my_under_args_parser.parse(argument_start_id)
|
||||||
|
# search help if needed ==> permit to not duplicating code
|
||||||
|
for elem in my_under_args:
|
||||||
|
if elem.get_option_name() == "help":
|
||||||
|
usage(my_under_args_parser, action_name)
|
||||||
return False
|
return False
|
||||||
return the_action.execute(argument_list)
|
# now we can execute:
|
||||||
|
if "execute" not in dir(the_action):
|
||||||
|
debug.error("execute is not implmented for this action ... '" + str(action_name) + "'")
|
||||||
|
return False
|
||||||
|
debug.info("execute: " + action_name)
|
||||||
|
for elem in my_under_args:
|
||||||
|
debug.info(" " + str(elem.get_option_name()) + "='" + str(elem.get_arg()) + "'")
|
||||||
|
return the_action.execute(my_under_args)
|
||||||
debug.error("Can not do the action...")
|
debug.error("Can not do the action...")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def get_action_help(action_name):
|
||||||
|
global list_actions;
|
||||||
|
for elem in list_actions:
|
||||||
|
if elem["name"] != action_name:
|
||||||
|
continue
|
||||||
|
sys.path.append(os.path.dirname(elem["path"]))
|
||||||
|
the_action = __import__(__base_action_name + action_name)
|
||||||
|
if "help" in dir(the_action):
|
||||||
|
return the_action.help()
|
||||||
|
return "---"
|
||||||
|
@ -20,21 +20,18 @@ import os
|
|||||||
def help():
|
def help():
|
||||||
return "plop"
|
return "plop"
|
||||||
|
|
||||||
|
def add_specific_arguments(my_args, section):
|
||||||
|
my_args.add("r", "remote", haveParam=True, desc="Name of the remote server")
|
||||||
|
my_args.add_arg("branch", optionnal=False, desc="Branch to checkout")
|
||||||
|
|
||||||
def execute(arguments):
|
def execute(arguments):
|
||||||
debug.info("execute:")
|
argument_remote_name = ""
|
||||||
for elem in arguments:
|
|
||||||
debug.info(" '" + str(elem.get_arg()) + "'")
|
|
||||||
if len(arguments) != 1:
|
|
||||||
debug.error("checkout: missing argument to select the new branch ...")
|
|
||||||
branch_to_checkout = ""
|
branch_to_checkout = ""
|
||||||
for elem in arguments:
|
for elem in arguments:
|
||||||
if elem.get_option_name() == "":
|
if elem.get_option_name() == "remote":
|
||||||
if branch_to_checkout != "":
|
debug.info("find remote name: '" + elem.get_arg() + "'")
|
||||||
debug.error("checkout branch already set : '" + branch_to_checkout + "' !!! '" + elem.get_arg() + "'")
|
argument_remote_name = elem.get_arg()
|
||||||
|
if elem.get_option_name() == "branch":
|
||||||
branch_to_checkout = elem.get_arg()
|
branch_to_checkout = elem.get_arg()
|
||||||
else:
|
else:
|
||||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||||
|
94
island/actions/islandAction_commit.py
Normal file
94
island/actions/islandAction_commit.py
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license MPL v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from island import debug
|
||||||
|
from island import tools
|
||||||
|
from island import env
|
||||||
|
from island import config
|
||||||
|
from island import multiprocess
|
||||||
|
from island import manifest
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def help():
|
||||||
|
return "commit in all repository"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def add_specific_arguments(my_args, section):
|
||||||
|
my_args.add("r", "remote", haveParam=True, desc="Name of the remote server")
|
||||||
|
my_args.add("m", "comment", haveParam=True, desc="Comment to commit data")
|
||||||
|
|
||||||
|
|
||||||
|
def execute(arguments):
|
||||||
|
argument_remote_name = ""
|
||||||
|
argument_comment = ""
|
||||||
|
for elem in arguments:
|
||||||
|
if elem.get_option_name() == "remote":
|
||||||
|
debug.info("find remote name: '" + elem.get_arg() + "'")
|
||||||
|
argument_remote_name = elem.get_arg()
|
||||||
|
if elem.get_option_name() == "comment":
|
||||||
|
debug.info("find comment: '" + elem.get_arg() + "'")
|
||||||
|
argument_comment = elem.get_arg()
|
||||||
|
else:
|
||||||
|
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||||
|
|
||||||
|
debug.info("commit with argument: ");
|
||||||
|
if argument_comment != "":
|
||||||
|
debug.info(" comment: '" + str(argument_comment) + "'");
|
||||||
|
exit(0);
|
||||||
|
|
||||||
|
# check if .XXX exist (create it if needed)
|
||||||
|
if os.path.exists(env.get_island_path()) == False \
|
||||||
|
or os.path.exists(env.get_island_path_config()) == False \
|
||||||
|
or os.path.exists(env.get_island_path_manifest()) == False:
|
||||||
|
debug.error("System already init have an error: missing data: '" + str(env.get_island_path()) + "'")
|
||||||
|
|
||||||
|
|
||||||
|
configuration = config.Config()
|
||||||
|
|
||||||
|
if env.get_fetch_manifest() == True:
|
||||||
|
debug.info("update manifest : '" + str(env.get_island_path_manifest()) + "'")
|
||||||
|
# update manifest
|
||||||
|
cmd = "git fetch --all"
|
||||||
|
multiprocess.run_command_direct(cmd, cwd=env.get_island_path_manifest())
|
||||||
|
|
||||||
|
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
|
if os.path.exists(file_source_manifest) == False:
|
||||||
|
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||||
|
mani = manifest.Manifest(file_source_manifest)
|
||||||
|
|
||||||
|
all_project = mani.get_all_configs()
|
||||||
|
debug.info("fetch : " + str(len(all_project)) + " projects")
|
||||||
|
id_element = 0
|
||||||
|
for elem in all_project:
|
||||||
|
id_element += 1
|
||||||
|
debug.info("fetch: " + str(id_element) + "/" + str(len(all_project)) + ": " + str(elem.name))
|
||||||
|
#debug.debug("elem : " + str(elem))
|
||||||
|
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||||
|
if os.path.exists(git_repo_path) == False:
|
||||||
|
debug.error("can not fetch project that not exist")
|
||||||
|
continue
|
||||||
|
|
||||||
|
if os.path.exists(os.path.join(git_repo_path,".git")) == False:
|
||||||
|
# path already exist but it is not used to as a git repo ==> this is an error
|
||||||
|
debug.error("path '" + git_repo_path + "' is already existing but not used for a git repository. Clean it and restart")
|
||||||
|
|
||||||
|
# simply update the repository ...
|
||||||
|
debug.verbose("Fetching project: ")
|
||||||
|
# fetch the repository
|
||||||
|
if argument_remote_name == "":
|
||||||
|
cmd = "git fetch " + elem.select_remote["name"]
|
||||||
|
else:
|
||||||
|
cmd = "git fetch " + argument_remote_name
|
||||||
|
debug.verbose("execute : " + cmd)
|
||||||
|
multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||||
|
|
@ -22,20 +22,18 @@ def help():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def add_specific_arguments(my_args, section):
|
||||||
|
my_args.add("r", "remote", haveParam=True, desc="Name of the remote server")
|
||||||
|
|
||||||
|
|
||||||
def execute(arguments):
|
def execute(arguments):
|
||||||
debug.info("execute:")
|
argument_remote_name = ""
|
||||||
origin_name = ""
|
|
||||||
for elem in arguments:
|
for elem in arguments:
|
||||||
debug.info(" '" + str(elem.get_arg()) + "'")
|
if elem.get_option_name() == "remote":
|
||||||
if len(arguments) == 0:
|
debug.info("find remote name: '" + elem.get_arg() + "'")
|
||||||
pass
|
argument_remote_name = elem.get_arg()
|
||||||
elif len(arguments) == 1:
|
else:
|
||||||
origin_name = arguments[0].get_arg()
|
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||||
debug.info("try fetch remote if exist: '" + str(origin_name) + "'")
|
|
||||||
else:
|
|
||||||
debug.error("Sync have not parameter")
|
|
||||||
|
|
||||||
# check if .XXX exist (create it if needed)
|
# check if .XXX exist (create it if needed)
|
||||||
if os.path.exists(env.get_island_path()) == False \
|
if os.path.exists(env.get_island_path()) == False \
|
||||||
@ -62,7 +60,7 @@ def execute(arguments):
|
|||||||
id_element = 0
|
id_element = 0
|
||||||
for elem in all_project:
|
for elem in all_project:
|
||||||
id_element += 1
|
id_element += 1
|
||||||
debug.info("fetch : " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name))
|
debug.info("fetch: " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name))
|
||||||
#debug.debug("elem : " + str(elem))
|
#debug.debug("elem : " + str(elem))
|
||||||
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||||
if os.path.exists(git_repo_path) == False:
|
if os.path.exists(git_repo_path) == False:
|
||||||
@ -76,10 +74,11 @@ def execute(arguments):
|
|||||||
# simply update the repository ...
|
# simply update the repository ...
|
||||||
debug.verbose("Fetching project: ")
|
debug.verbose("Fetching project: ")
|
||||||
# fetch the repository
|
# fetch the repository
|
||||||
if origin_name == "":
|
cmd = "git fetch"
|
||||||
cmd = "git fetch " + elem.select_remote["name"]
|
if argument_remote_name != "":
|
||||||
|
cmd += " " + argument_remote_name
|
||||||
else:
|
else:
|
||||||
cmd = "git fetch " + origin_name
|
cmd += " " + elem.select_remote["name"]
|
||||||
debug.verbose("execute : " + cmd)
|
debug.verbose("execute : " + cmd)
|
||||||
multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||||
|
|
||||||
|
@ -16,12 +16,14 @@ from island import multiprocess
|
|||||||
import os
|
import os
|
||||||
|
|
||||||
def help():
|
def help():
|
||||||
return "plop"
|
return "Init a island repository (need 'fetch' after)"
|
||||||
|
|
||||||
|
def add_specific_arguments(my_args, section):
|
||||||
|
my_args.add("b", "branch", haveParam=True, desc="Select branch to display")
|
||||||
|
my_args.add("m", "manifest", haveParam=True, desc="Name of the manifest")
|
||||||
|
|
||||||
|
|
||||||
def execute(arguments):
|
def execute(arguments):
|
||||||
debug.info("execute:")
|
|
||||||
for elem in arguments:
|
|
||||||
debug.info(" '" + str(elem.get_arg()) + "'")
|
|
||||||
if len(arguments) == 0:
|
if len(arguments) == 0:
|
||||||
debug.error("Missing argument to execute the current action ...")
|
debug.error("Missing argument to execute the current action ...")
|
||||||
|
|
||||||
|
107
island/actions/islandAction_push.py
Normal file
107
island/actions/islandAction_push.py
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license MPL v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from island import debug
|
||||||
|
from island import tools
|
||||||
|
from island import env
|
||||||
|
from island import config
|
||||||
|
from island import multiprocess
|
||||||
|
from island import manifest
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def help():
|
||||||
|
return "Push all repository to the upper server"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def add_specific_arguments(my_args, section):
|
||||||
|
my_args.add("r", "remote", haveParam=True, desc="Name of the remote server")
|
||||||
|
|
||||||
|
|
||||||
|
def execute(arguments):
|
||||||
|
argument_remote_name = ""
|
||||||
|
for elem in arguments:
|
||||||
|
if elem.get_option_name() == "remote":
|
||||||
|
debug.info("find remote name: '" + elem.get_arg() + "'")
|
||||||
|
argument_remote_name = elem.get_arg()
|
||||||
|
else:
|
||||||
|
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||||
|
|
||||||
|
# check if .XXX exist (create it if needed)
|
||||||
|
if os.path.exists(env.get_island_path()) == False \
|
||||||
|
or os.path.exists(env.get_island_path_config()) == False \
|
||||||
|
or os.path.exists(env.get_island_path_manifest()) == False:
|
||||||
|
debug.error("System already init have an error: missing data: '" + str(env.get_island_path()) + "'")
|
||||||
|
|
||||||
|
|
||||||
|
configuration = config.Config()
|
||||||
|
|
||||||
|
if env.get_fetch_manifest() == True:
|
||||||
|
debug.info("update manifest : '" + str(env.get_island_path_manifest()) + "'")
|
||||||
|
# update manifest
|
||||||
|
cmd = "git fetch --all"
|
||||||
|
multiprocess.run_command_direct(cmd, cwd=env.get_island_path_manifest())
|
||||||
|
|
||||||
|
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
|
if os.path.exists(file_source_manifest) == False:
|
||||||
|
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||||
|
mani = manifest.Manifest(file_source_manifest)
|
||||||
|
|
||||||
|
all_project = mani.get_all_configs()
|
||||||
|
debug.info("fetch : " + str(len(all_project)) + " projects")
|
||||||
|
id_element = 0
|
||||||
|
for elem in all_project:
|
||||||
|
id_element += 1
|
||||||
|
debug.info("push: " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name))
|
||||||
|
#debug.debug("elem : " + str(elem))
|
||||||
|
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||||
|
if os.path.exists(git_repo_path) == False:
|
||||||
|
debug.error("can not push project that not exist")
|
||||||
|
continue
|
||||||
|
|
||||||
|
if os.path.exists(os.path.join(git_repo_path,".git")) == False:
|
||||||
|
# path already exist but it is not used to as a git repo ==> this is an error
|
||||||
|
debug.error("path '" + git_repo_path + "' exist but not used for a git repository. Clean it and restart")
|
||||||
|
|
||||||
|
# get the current branch:
|
||||||
|
# get local branch
|
||||||
|
cmd = "git branch -a"
|
||||||
|
debug.verbose("execute : " + cmd)
|
||||||
|
ret_branch = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||||
|
list_branch = ret_branch[1].split('\n')
|
||||||
|
list_branch2 = []
|
||||||
|
list_branch3 = []
|
||||||
|
select_branch = ""
|
||||||
|
for elem_branch in list_branch:
|
||||||
|
if len(elem_branch.split(" -> ")) != 1:
|
||||||
|
continue
|
||||||
|
if elem_branch[2:10] == "remotes/":
|
||||||
|
elem_branch = elem_branch[:2] + elem_branch[10:]
|
||||||
|
if elem_branch[:2] == "* ":
|
||||||
|
list_branch2.append([elem_branch[2:], True])
|
||||||
|
select_branch = elem_branch[2:]
|
||||||
|
else:
|
||||||
|
list_branch2.append([elem_branch[2:], False])
|
||||||
|
list_branch3.append(elem_branch[2:])
|
||||||
|
|
||||||
|
# simply update the repository ...
|
||||||
|
debug.verbose("Push project: ")
|
||||||
|
# fetch the repository
|
||||||
|
cmd = "git push"
|
||||||
|
if argument_remote_name != "":
|
||||||
|
cmd += " " + argument_remote_name
|
||||||
|
else:
|
||||||
|
cmd += " " + elem.select_remote["name"]
|
||||||
|
cmd += " " + elem_branch + ":" + elem_branch
|
||||||
|
debug.verbose("execute : " + cmd)
|
||||||
|
multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||||
|
|
@ -21,18 +21,18 @@ def help():
|
|||||||
return "plop"
|
return "plop"
|
||||||
|
|
||||||
|
|
||||||
|
def add_specific_arguments(my_args, section):
|
||||||
|
my_args.add("r", "remote", haveParam=True, desc="Name of the remote server")
|
||||||
|
|
||||||
|
|
||||||
def execute(arguments):
|
def execute(arguments):
|
||||||
debug.info("execute:")
|
argument_remote_name = ""
|
||||||
origin_name = ""
|
|
||||||
for elem in arguments:
|
for elem in arguments:
|
||||||
debug.info(" '" + str(elem.get_arg()) + "'")
|
if elem.get_option_name() == "remote":
|
||||||
if len(arguments) == 0:
|
debug.info("find remote name: '" + elem.get_arg() + "'")
|
||||||
pass
|
argument_remote_name = elem.get_arg()
|
||||||
elif len(arguments) == 1:
|
else:
|
||||||
origin_name = arguments[0].get_arg()
|
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||||
debug.info("try fetch remote if exist: '" + str(origin_name) + "'")
|
|
||||||
else:
|
|
||||||
debug.error("Sync have not parameter")
|
|
||||||
|
|
||||||
# check if .XXX exist (create it if needed)
|
# check if .XXX exist (create it if needed)
|
||||||
if os.path.exists(env.get_island_path()) == False \
|
if os.path.exists(env.get_island_path()) == False \
|
||||||
@ -90,17 +90,17 @@ def execute(arguments):
|
|||||||
list_branch3.append(elem_branch[2:])
|
list_branch3.append(elem_branch[2:])
|
||||||
debug.verbose("List all branch: " + str(list_branch3))
|
debug.verbose("List all branch: " + str(list_branch3))
|
||||||
# get tracking branch
|
# get tracking branch
|
||||||
if origin_name == "":
|
if argument_remote_name == "":
|
||||||
cmd = "git rev-parse --abbrev-ref --symbolic-full-name @{u}"
|
cmd = "git rev-parse --abbrev-ref --symbolic-full-name @{u}"
|
||||||
debug.verbose("execute : " + cmd)
|
debug.verbose("execute : " + cmd)
|
||||||
ret_track = multiprocess.run_command(cmd, cwd=git_repo_path)
|
ret_track = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||||
else:
|
else:
|
||||||
debug.extreme_verbose("check if exist " + origin_name + "/" + select_branch + " in " + str(list_branch3))
|
debug.extreme_verbose("check if exist " + argument_remote_name + "/" + select_branch + " in " + str(list_branch3))
|
||||||
if origin_name + "/" + select_branch not in list_branch3:
|
if argument_remote_name + "/" + select_branch not in list_branch3:
|
||||||
debug.info("" + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + "\r\t\t\t\t\t\t\t (NO BRANCH)")
|
debug.info("" + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + "\r\t\t\t\t\t\t\t (NO BRANCH)")
|
||||||
continue;
|
continue;
|
||||||
else:
|
else:
|
||||||
ret_track = [True, origin_name + "/" + select_branch]
|
ret_track = [True, argument_remote_name + "/" + select_branch]
|
||||||
|
|
||||||
modify_status = " "
|
modify_status = " "
|
||||||
if is_modify == True:
|
if is_modify == True:
|
||||||
|
@ -23,11 +23,7 @@ def help():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def execute(arguments):
|
def execute(arguments):
|
||||||
debug.info("execute:")
|
|
||||||
for elem in arguments:
|
|
||||||
debug.info(" '" + str(elem.get_arg()) + "'")
|
|
||||||
if len(arguments) != 0:
|
if len(arguments) != 0:
|
||||||
debug.error("Sync have not parameter")
|
debug.error("Sync have not parameter")
|
||||||
|
|
||||||
|
@ -83,6 +83,8 @@ class ArgDefine:
|
|||||||
self.have_param = False
|
self.have_param = False
|
||||||
self.description = desc;
|
self.description = desc;
|
||||||
|
|
||||||
|
def is_parsable(self):
|
||||||
|
return True
|
||||||
##
|
##
|
||||||
## @brief Get the small name of the option ex: '-v'
|
## @brief Get the small name of the option ex: '-v'
|
||||||
## @param[in] self Class handle
|
## @param[in] self Class handle
|
||||||
@ -165,6 +167,88 @@ class ArgDefine:
|
|||||||
print(" { " + tmpElementPrint + " }")
|
print(" { " + tmpElementPrint + " }")
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Declare an argument value and store it in a parameter
|
||||||
|
##
|
||||||
|
class ArgVolatile:
|
||||||
|
##
|
||||||
|
## @brief Contructor.
|
||||||
|
## @param[in] self Class handle
|
||||||
|
## @param[in] dest_option (string) Where to store the option name
|
||||||
|
## @param[in] optionnal (bool) this element can be not present
|
||||||
|
## @param[in] desc (string) user friendly description with this parameter (default "")
|
||||||
|
##
|
||||||
|
def __init__(self,
|
||||||
|
dest_option="",
|
||||||
|
optionnal=False,
|
||||||
|
desc=""):
|
||||||
|
self.dest_option = dest_option;
|
||||||
|
if dest_option == "":
|
||||||
|
debug.error("volatil argument must be store in an argument name")
|
||||||
|
self.optionnal = optionnal;
|
||||||
|
self.description = desc;
|
||||||
|
self.count = 0;
|
||||||
|
|
||||||
|
def is_parsable(self):
|
||||||
|
return False
|
||||||
|
##
|
||||||
|
## @brief Get the small name of the option ex: '-v'
|
||||||
|
## @param[in] self Class handle
|
||||||
|
## @return (string) Small name value
|
||||||
|
##
|
||||||
|
def get_option_small(self):
|
||||||
|
return ""
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get the big name of the option ex: '--verbose'
|
||||||
|
## @param[in] self Class handle
|
||||||
|
## @return (string) Big name value
|
||||||
|
##
|
||||||
|
def get_option_big(self):
|
||||||
|
return self.dest_option
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Get the status of getting user parameter value
|
||||||
|
## @param[in] self Class handle
|
||||||
|
## @return True The user must write a value
|
||||||
|
## @return False The user must NOT write a value
|
||||||
|
##
|
||||||
|
def need_parameters(self):
|
||||||
|
if self.count == 0:
|
||||||
|
self.count += 1
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Compatibility with @ref ArgSection class
|
||||||
|
## @param[in] self Class handle
|
||||||
|
## @return (string) empty string
|
||||||
|
##
|
||||||
|
def get_porperties(self):
|
||||||
|
return "???? WHAT the fuck ????"
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Check if the user added value is correct or not with the list of availlable value
|
||||||
|
## @param[in] self Class handle
|
||||||
|
## @param[in] argument (string) User parameter value (string)
|
||||||
|
## @return True The parameter is OK
|
||||||
|
## @return False The parameter is NOT Availlable
|
||||||
|
##
|
||||||
|
def check_availlable(self, argument):
|
||||||
|
return True
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Display the argument property when user request help
|
||||||
|
## @param[in] self Class handle
|
||||||
|
##
|
||||||
|
def display(self):
|
||||||
|
color = debug.get_color_set()
|
||||||
|
print(" " + color['red'] + "[" + self.dest_option + "]" + color['default'])
|
||||||
|
if self.optionnal == True:
|
||||||
|
print("(OPTIONNAL)")
|
||||||
|
if self.description != "":
|
||||||
|
print(" " + self.description)
|
||||||
|
|
||||||
##
|
##
|
||||||
## @brief Section Class definition (permit to add a comment when requesting help
|
## @brief Section Class definition (permit to add a comment when requesting help
|
||||||
##
|
##
|
||||||
@ -181,6 +265,9 @@ class ArgSection:
|
|||||||
self.section = sectionName;
|
self.section = sectionName;
|
||||||
self.description = desc;
|
self.description = desc;
|
||||||
|
|
||||||
|
def is_parsable(self):
|
||||||
|
return False
|
||||||
|
|
||||||
##
|
##
|
||||||
## @brief Compatibility with @ref ArgDefine class
|
## @brief Compatibility with @ref ArgDefine class
|
||||||
## @param[in] self Class handle
|
## @param[in] self Class handle
|
||||||
@ -215,6 +302,9 @@ class ArgSection:
|
|||||||
print(" [" + color['blue'] + self.section + color['default'] + "] : " + self.description)
|
print(" [" + color['blue'] + self.section + color['default'] + "] : " + self.description)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
## @brief Class to define the agmument list availlable for a program
|
## @brief Class to define the agmument list availlable for a program
|
||||||
##
|
##
|
||||||
@ -225,6 +315,8 @@ class islandArg:
|
|||||||
##
|
##
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.list_properties = []
|
self.list_properties = []
|
||||||
|
self._list_element_stop = []
|
||||||
|
self._last_element_parsed = 0
|
||||||
|
|
||||||
##
|
##
|
||||||
## @brief Add a new argument possibilities...
|
## @brief Add a new argument possibilities...
|
||||||
@ -238,6 +330,9 @@ class islandArg:
|
|||||||
def add(self, smallOption="", bigOption="", list=[], desc="", haveParam=False):
|
def add(self, smallOption="", bigOption="", list=[], desc="", haveParam=False):
|
||||||
self.list_properties.append(ArgDefine(smallOption, bigOption, list, desc, haveParam))
|
self.list_properties.append(ArgDefine(smallOption, bigOption, list, desc, haveParam))
|
||||||
|
|
||||||
|
def add_arg(self, destOption="", optionnal=False, desc=""):
|
||||||
|
self.list_properties.append(ArgVolatile(destOption, optionnal, desc))
|
||||||
|
|
||||||
##
|
##
|
||||||
## @brief Add section on argument list
|
## @brief Add section on argument list
|
||||||
## @param[in] self Class handle
|
## @param[in] self Class handle
|
||||||
@ -250,17 +345,24 @@ class islandArg:
|
|||||||
##
|
##
|
||||||
## @brief Parse the argument set in the command line
|
## @brief Parse the argument set in the command line
|
||||||
## @param[in] self Class handle
|
## @param[in] self Class handle
|
||||||
|
## @param[in] start_position_parsing position to start the parsing in the arguments
|
||||||
##
|
##
|
||||||
def parse(self):
|
def parse(self, start_position_parsing=1):
|
||||||
listArgument = [] # composed of list element
|
list_argument = [] # composed of list element
|
||||||
NotparseNextElement=False
|
not_parse_next_element=False
|
||||||
for iii in range(1, len(sys.argv)):
|
for iii in range(start_position_parsing, len(sys.argv)):
|
||||||
|
self._last_element_parsed = iii
|
||||||
# special case of parameter in some elements
|
# special case of parameter in some elements
|
||||||
if NotparseNextElement==True:
|
if not_parse_next_element == True:
|
||||||
NotparseNextElement = False
|
not_parse_next_element = False
|
||||||
continue
|
continue
|
||||||
debug.verbose("parse [" + str(iii) + "]=" + sys.argv[iii])
|
debug.verbose("parse [" + str(iii) + "]=" + sys.argv[iii])
|
||||||
argument = sys.argv[iii]
|
argument = sys.argv[iii]
|
||||||
|
# check if we get a stop parsing element:
|
||||||
|
if argument in self._list_element_stop:
|
||||||
|
debug.warning("stop at position: " + str(iii))
|
||||||
|
list_argument.append(ArgElement("", argument))
|
||||||
|
break;
|
||||||
optionList = argument.split("=")
|
optionList = argument.split("=")
|
||||||
debug.verbose(str(optionList))
|
debug.verbose(str(optionList))
|
||||||
if type(optionList) == type(str()):
|
if type(optionList) == type(str()):
|
||||||
@ -269,10 +371,12 @@ class islandArg:
|
|||||||
option = optionList[0]
|
option = optionList[0]
|
||||||
optionParam = argument[len(option)+1:]
|
optionParam = argument[len(option)+1:]
|
||||||
debug.verbose(option)
|
debug.verbose(option)
|
||||||
argumentFound=False;
|
argument_found=False;
|
||||||
if option[:2]=="--":
|
if option[:2] == "--":
|
||||||
# big argument
|
# big argument
|
||||||
for prop in self.list_properties:
|
for prop in self.list_properties:
|
||||||
|
if prop.is_parsable()==False:
|
||||||
|
continue
|
||||||
if prop.get_option_big()=="":
|
if prop.get_option_big()=="":
|
||||||
continue
|
continue
|
||||||
if prop.get_option_big() == option[2:]:
|
if prop.get_option_big() == option[2:]:
|
||||||
@ -291,7 +395,7 @@ class islandArg:
|
|||||||
#Get the next parameters
|
#Get the next parameters
|
||||||
if len(sys.argv) > iii+1:
|
if len(sys.argv) > iii+1:
|
||||||
optionParam = sys.argv[iii+1]
|
optionParam = sys.argv[iii+1]
|
||||||
NotparseNextElement=True
|
not_parse_next_element=True
|
||||||
else :
|
else :
|
||||||
# missing arguments
|
# missing arguments
|
||||||
debug.warning("parsing argument error : '" + prop.get_option_big() + "' Missing : subParameters ... cmdLine='" + argument + "'")
|
debug.warning("parsing argument error : '" + prop.get_option_big() + "' Missing : subParameters ... cmdLine='" + argument + "'")
|
||||||
@ -301,20 +405,22 @@ class islandArg:
|
|||||||
debug.warning("argument error : '" + prop.get_option_big() + "' SubParameters not availlable ... cmdLine='" + argument + "' option='" + optionParam + "'")
|
debug.warning("argument error : '" + prop.get_option_big() + "' SubParameters not availlable ... cmdLine='" + argument + "' option='" + optionParam + "'")
|
||||||
prop.display()
|
prop.display()
|
||||||
exit(-1)
|
exit(-1)
|
||||||
listArgument.append(ArgElement(prop.get_option_big(),optionParam))
|
list_argument.append(ArgElement(prop.get_option_big(),optionParam))
|
||||||
argumentFound = True
|
argument_found = True
|
||||||
else:
|
else:
|
||||||
if len(optionParam)!=0:
|
if len(optionParam)!=0:
|
||||||
debug.warning("parsing argument error : '" + prop.get_option_big() + "' need no subParameters : '" + optionParam + "' cmdLine='" + argument + "'")
|
debug.warning("parsing argument error : '" + prop.get_option_big() + "' need no subParameters : '" + optionParam + "' cmdLine='" + argument + "'")
|
||||||
prop.display()
|
prop.display()
|
||||||
listArgument.append(ArgElement(prop.get_option_big()))
|
list_argument.append(ArgElement(prop.get_option_big()))
|
||||||
argumentFound = True
|
argument_found = True
|
||||||
break;
|
break;
|
||||||
if False==argumentFound:
|
if argument_found == False:
|
||||||
debug.error("UNKNOW argument : '" + argument + "'")
|
debug.error("UNKNOW argument : '" + argument + "'")
|
||||||
elif option[:1]=="-":
|
elif option[:1]=="-":
|
||||||
# small argument
|
# small argument
|
||||||
for prop in self.list_properties:
|
for prop in self.list_properties:
|
||||||
|
if prop.is_parsable()==False:
|
||||||
|
continue
|
||||||
if prop.get_option_small()=="":
|
if prop.get_option_small()=="":
|
||||||
continue
|
continue
|
||||||
if prop.get_option_small() == option[1:1+len(prop.get_option_small())]:
|
if prop.get_option_small() == option[1:1+len(prop.get_option_small())]:
|
||||||
@ -333,7 +439,7 @@ class islandArg:
|
|||||||
#Get the next parameters
|
#Get the next parameters
|
||||||
if len(sys.argv) > iii+1:
|
if len(sys.argv) > iii+1:
|
||||||
optionParam = sys.argv[iii+1]
|
optionParam = sys.argv[iii+1]
|
||||||
NotparseNextElement=True
|
not_parse_next_element=True
|
||||||
else :
|
else :
|
||||||
# missing arguments
|
# missing arguments
|
||||||
debug.warning("parsing argument error : '" + prop.get_option_big() + "' Missing : subParameters cmdLine='" + argument + "'")
|
debug.warning("parsing argument error : '" + prop.get_option_big() + "' Missing : subParameters cmdLine='" + argument + "'")
|
||||||
@ -343,36 +449,69 @@ class islandArg:
|
|||||||
debug.warning("argument error : '" + prop.get_option_big() + "' SubParameters not availlable ... cmdLine='" + argument + "' option='" + optionParam + "'")
|
debug.warning("argument error : '" + prop.get_option_big() + "' SubParameters not availlable ... cmdLine='" + argument + "' option='" + optionParam + "'")
|
||||||
prop.display()
|
prop.display()
|
||||||
exit(-1)
|
exit(-1)
|
||||||
listArgument.append(ArgElement(prop.get_option_big(),optionParam))
|
list_argument.append(ArgElement(prop.get_option_big(),optionParam))
|
||||||
argumentFound = True
|
argument_found = True
|
||||||
else:
|
else:
|
||||||
if len(optionParam)!=0:
|
if len(optionParam)!=0:
|
||||||
debug.warning("parsing argument error : '" + prop.get_option_big() + "' need no subParameters : '" + optionParam + "' cmdLine='" + argument + "'")
|
debug.warning("parsing argument error : '" + prop.get_option_big() + "' need no subParameters : '" + optionParam + "' cmdLine='" + argument + "'")
|
||||||
prop.display()
|
prop.display()
|
||||||
listArgument.append(ArgElement(prop.get_option_big()))
|
list_argument.append(ArgElement(prop.get_option_big()))
|
||||||
argumentFound = True
|
argument_found = True
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if argumentFound==False:
|
if argument_found==False:
|
||||||
|
# small argument
|
||||||
|
for prop in self.list_properties:
|
||||||
|
if prop.is_parsable() == True \
|
||||||
|
or prop.get_option_big() == "":
|
||||||
|
continue
|
||||||
|
if prop.need_parameters() == True:
|
||||||
|
list_argument.append(ArgElement(prop.get_option_big(), argument))
|
||||||
|
argument_found = True
|
||||||
|
break
|
||||||
|
if argument_found==False:
|
||||||
#unknow element ... ==> just add in the list ...
|
#unknow element ... ==> just add in the list ...
|
||||||
debug.verbose("unknow argument : " + argument)
|
debug.verbose("unknow argument : " + argument)
|
||||||
listArgument.append(ArgElement("", argument))
|
list_argument.append(ArgElement("", argument))
|
||||||
|
|
||||||
#for argument in listArgument:
|
for prop in self.list_properties:
|
||||||
|
if prop.is_parsable() == True \
|
||||||
|
or prop.get_option_big() == "":
|
||||||
|
continue
|
||||||
|
if prop.need_parameters() == True \
|
||||||
|
and prop.optionnal == False:
|
||||||
|
debug.error("Missing argument:" + prop.get_option_big())
|
||||||
|
#for argument in list_argument:
|
||||||
# argument.display()
|
# argument.display()
|
||||||
#exit(0)
|
#exit(0)
|
||||||
return listArgument;
|
return list_argument;
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief Stop parsing at a specific position
|
||||||
|
## @param[in] self Class handle
|
||||||
|
## @param[in] list_of_element List of element that stop the parsing
|
||||||
|
##
|
||||||
|
def set_stop_at(self, list_of_element):
|
||||||
|
self._list_element_stop = list_of_element
|
||||||
|
|
||||||
|
##
|
||||||
|
## @brief get the last element parsed.
|
||||||
|
## @param[in] self Class handle
|
||||||
|
##
|
||||||
|
def get_last_parsed(self):
|
||||||
|
return self._last_element_parsed
|
||||||
|
|
||||||
##
|
##
|
||||||
## @brief Display help on console output
|
## @brief Display help on console output
|
||||||
## @param[in] self Class handle
|
## @param[in] self Class handle
|
||||||
|
## @param[in] action_name opation to set at the end of the application name
|
||||||
##
|
##
|
||||||
def display(self):
|
def display(self, action_name=""):
|
||||||
print("usage:")
|
print("usage:")
|
||||||
listOfPropertiesArg = "";
|
listOfPropertiesArg = "";
|
||||||
for element in self.list_properties :
|
for element in self.list_properties :
|
||||||
listOfPropertiesArg += element.get_porperties()
|
listOfPropertiesArg += element.get_porperties()
|
||||||
print(" " + sys.argv[0] + listOfPropertiesArg + " ...")
|
print(" " + sys.argv[0] + listOfPropertiesArg + " " + action_name + " ...")
|
||||||
for element in self.list_properties :
|
for element in self.list_properties :
|
||||||
element.display()
|
element.display()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user