Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
10f40f4d00 | |||
1a7129d632 | |||
49874b7785 | |||
6fda840ae5 | |||
7a46b3c0f9 | |||
bc556ee89b | |||
7f88a7cc34 | |||
9f11499b34 | |||
6da4400509 | |||
0f47c841fd | |||
bc82c533f1 | |||
f8de06c4d9 |
@@ -54,35 +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("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 ")
|
||||||
@@ -131,6 +129,10 @@ def parseGenericArg(argument, active):
|
|||||||
else:
|
else:
|
||||||
debug.disable_color()
|
debug.disable_color()
|
||||||
return True
|
return True
|
||||||
|
elif argument.get_option_name() == "no-fetch-manifest":
|
||||||
|
if active == False:
|
||||||
|
env.set_fetch_manifest(False)
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -186,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)
|
||||||
@@ -225,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:
|
||||||
|
continue
|
||||||
debug.info("action: " + str(elem));
|
debug.info("action: " + str(elem));
|
||||||
# finish the parsing
|
# finish the parsing
|
||||||
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)
|
||||||
|
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
|
||||||
|
# now we can execute:
|
||||||
if "execute" not in dir(the_action):
|
if "execute" not in dir(the_action):
|
||||||
debug.error("execute is not implmented for this action ... '" + str(action_name) + "'")
|
debug.error("execute is not implmented for this action ... '" + str(action_name) + "'")
|
||||||
return False
|
return False
|
||||||
return the_action.execute(argument_list)
|
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()
|
||||||
|
elif 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() + "'")
|
||||||
|
88
island/actions/islandAction_commit.py
Normal file
88
island/actions/islandAction_commit.py
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
#!/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("m", "message", haveParam=True, desc="Message to commit data")
|
||||||
|
my_args.add("a", "all", desc="Commit all elements")
|
||||||
|
my_args.add("", "amend", desc="Ammend data at the previous commit")
|
||||||
|
|
||||||
|
|
||||||
|
def execute(arguments):
|
||||||
|
argument_message = ""
|
||||||
|
argument_amend = ""
|
||||||
|
argument_all = ""
|
||||||
|
for elem in arguments:
|
||||||
|
if elem.get_option_name() == "message":
|
||||||
|
debug.info("find message: '" + elem.get_arg() + "'")
|
||||||
|
argument_message = " --message \"" + elem.get_arg() + "\" ";
|
||||||
|
elif elem.get_option_name() == "all":
|
||||||
|
argument_all = " --all "
|
||||||
|
elif elem.get_option_name() == "amend":
|
||||||
|
argument_amend = " --amend "
|
||||||
|
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("commit : " + str(len(all_project)) + " projects")
|
||||||
|
id_element = 0
|
||||||
|
for elem in all_project:
|
||||||
|
id_element += 1
|
||||||
|
debug.info("commit: " + str(id_element) + "/" + str(len(all_project)) + ": " + str(elem.name))
|
||||||
|
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 commit 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.warning("path '" + git_repo_path + "' is already existing but not used for a git repository. Clean it and restart")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
# simply update the repository ...
|
||||||
|
debug.verbose("commit in project:")
|
||||||
|
# fetch the repository
|
||||||
|
cmd = "git commit " + argument_amend + argument_all + argument_message
|
||||||
|
debug.debug("execute : " + cmd)
|
||||||
|
multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||||
|
|
@@ -20,16 +20,17 @@ 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")
|
||||||
|
|
||||||
|
|
||||||
def execute(arguments):
|
def execute(arguments):
|
||||||
debug.info("execute:")
|
argument_remote_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() + "'")
|
||||||
debug.error("Sync have not parameter")
|
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)
|
# 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 \
|
||||||
@@ -40,6 +41,7 @@ def execute(arguments):
|
|||||||
|
|
||||||
configuration = config.Config()
|
configuration = config.Config()
|
||||||
|
|
||||||
|
if env.get_fetch_manifest() == True:
|
||||||
debug.info("update manifest : '" + str(env.get_island_path_manifest()) + "'")
|
debug.info("update manifest : '" + str(env.get_island_path_manifest()) + "'")
|
||||||
# update manifest
|
# update manifest
|
||||||
cmd = "git fetch --all"
|
cmd = "git fetch --all"
|
||||||
@@ -69,7 +71,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
|
||||||
cmd = "git fetch " + elem.select_remote["name"]
|
cmd = "git fetch"
|
||||||
|
if argument_remote_name != "":
|
||||||
|
cmd += " " + argument_remote_name
|
||||||
|
else:
|
||||||
|
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 += " " + select_branch + ":" + select_branch
|
||||||
|
debug.info("execute : " + cmd)
|
||||||
|
multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||||
|
|
@@ -21,15 +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 = ""
|
||||||
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() + "'")
|
||||||
debug.error("status have not parameter")
|
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)
|
# 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,28 +65,42 @@ def execute(arguments):
|
|||||||
debug.verbose("execute : " + cmd)
|
debug.verbose("execute : " + cmd)
|
||||||
ret_diff = multiprocess.run_command(cmd, cwd=git_repo_path)
|
ret_diff = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||||
# get local branch
|
# get local branch
|
||||||
cmd = "git branch"
|
cmd = "git branch -a"
|
||||||
debug.verbose("execute : " + cmd)
|
debug.verbose("execute : " + cmd)
|
||||||
ret_branch = multiprocess.run_command(cmd, cwd=git_repo_path)
|
ret_branch = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||||
|
|
||||||
# get tracking branch
|
|
||||||
cmd = "git rev-parse --abbrev-ref --symbolic-full-name @{u}"
|
|
||||||
debug.verbose("execute : " + cmd)
|
|
||||||
ret_track = multiprocess.run_command(cmd, cwd=git_repo_path)
|
|
||||||
|
|
||||||
is_modify = True
|
is_modify = True
|
||||||
if ret_diff[0] == 0:
|
if ret_diff[0] == 0:
|
||||||
is_modify = False
|
is_modify = False
|
||||||
|
|
||||||
list_branch = ret_branch[1].split('\n')
|
list_branch = ret_branch[1].split('\n')
|
||||||
list_branch2 = []
|
list_branch2 = []
|
||||||
|
list_branch3 = []
|
||||||
select_branch = ""
|
select_branch = ""
|
||||||
for elem_branch in list_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] == "* ":
|
if elem_branch[:2] == "* ":
|
||||||
list_branch2.append([elem_branch[2:], True])
|
list_branch2.append([elem_branch[2:], True])
|
||||||
select_branch = elem_branch[2:]
|
select_branch = elem_branch[2:]
|
||||||
else:
|
else:
|
||||||
list_branch2.append([elem_branch[2:], False])
|
list_branch2.append([elem_branch[2:], False])
|
||||||
|
list_branch3.append(elem_branch[2:])
|
||||||
|
debug.verbose("List all branch: " + str(list_branch3))
|
||||||
|
# get tracking branch
|
||||||
|
if argument_remote_name == "":
|
||||||
|
cmd = "git rev-parse --abbrev-ref --symbolic-full-name @{u}"
|
||||||
|
debug.verbose("execute : " + cmd)
|
||||||
|
ret_track = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||||
|
else:
|
||||||
|
debug.extreme_verbose("check if exist " + argument_remote_name + "/" + select_branch + " in " + str(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)")
|
||||||
|
continue;
|
||||||
|
else:
|
||||||
|
ret_track = [True, argument_remote_name + "/" + select_branch]
|
||||||
|
|
||||||
modify_status = " "
|
modify_status = " "
|
||||||
if is_modify == True:
|
if is_modify == True:
|
||||||
@@ -111,6 +128,8 @@ def execute(arguments):
|
|||||||
if in_forward != 0:
|
if in_forward != 0:
|
||||||
behind_forward_comment += "forward=" + str(in_forward)
|
behind_forward_comment += "forward=" + str(in_forward)
|
||||||
if in_behind != 0:
|
if in_behind != 0:
|
||||||
|
if in_forward != 0:
|
||||||
|
behind_forward_comment += " "
|
||||||
behind_forward_comment += "behind=" + str(in_behind)
|
behind_forward_comment += "behind=" + str(in_behind)
|
||||||
if behind_forward_comment != "":
|
if behind_forward_comment != "":
|
||||||
behind_forward_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t[" + behind_forward_comment + "]"
|
behind_forward_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t[" + behind_forward_comment + "]"
|
||||||
|
@@ -21,15 +21,17 @@ def help():
|
|||||||
return "plop"
|
return "plop"
|
||||||
|
|
||||||
|
|
||||||
|
def add_specific_arguments(my_args, section):
|
||||||
|
my_args.add("d", "download", haveParam=False, desc="Just download not download repository")
|
||||||
|
|
||||||
def execute(arguments):
|
def execute(arguments):
|
||||||
debug.info("execute:")
|
just_download = False
|
||||||
for elem in arguments:
|
for elem in arguments:
|
||||||
debug.info(" '" + str(elem.get_arg()) + "'")
|
if elem.get_option_name() == "download":
|
||||||
if len(arguments) != 0:
|
just_download = True
|
||||||
debug.error("Sync have not parameter")
|
debug.info("find remote name: '" + elem.get_arg() + "'")
|
||||||
|
else:
|
||||||
|
debug.error("SYNC Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||||
|
|
||||||
# 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 \
|
||||||
@@ -63,8 +65,14 @@ def execute(arguments):
|
|||||||
# this is a new clone ==> this is easy ...
|
# this is a new clone ==> this is easy ...
|
||||||
#clone the manifest repository
|
#clone the manifest repository
|
||||||
address_manifest = ""
|
address_manifest = ""
|
||||||
|
### example git@git.plouf.com:basic_folder
|
||||||
cmd = "git clone " + elem.select_remote["fetch"] + "/" + elem.name + " --branch " + elem.branch + " --origin " + elem.select_remote["name"] + " " + git_repo_path
|
cmd = "git clone " + elem.select_remote["fetch"]
|
||||||
|
if elem.select_remote["fetch"][0:4] == "git@" \
|
||||||
|
and len(elem.select_remote["fetch"][4:].split(":")) <= 1:
|
||||||
|
cmd += ":"
|
||||||
|
else:
|
||||||
|
cmd += "/"
|
||||||
|
cmd += elem.name + " --branch " + elem.branch + " --origin " + elem.select_remote["name"] + " " + git_repo_path
|
||||||
debug.info("clone the repo")
|
debug.info("clone the repo")
|
||||||
ret = multiprocess.run_command_direct(cmd)
|
ret = multiprocess.run_command_direct(cmd)
|
||||||
if ret != "" \
|
if ret != "" \
|
||||||
@@ -76,7 +84,12 @@ def execute(arguments):
|
|||||||
# add global mirror list
|
# add global mirror list
|
||||||
for mirror in elem.select_remote["mirror"]:
|
for mirror in elem.select_remote["mirror"]:
|
||||||
debug.verbose("Add global mirror: " + str(mirror))
|
debug.verbose("Add global mirror: " + str(mirror))
|
||||||
cmd = "git remote add " + mirror["name"] + " " + mirror["fetch"] + "/" + elem.name
|
cmd = "git remote add " + mirror["name"] + " " + mirror["fetch"]
|
||||||
|
if mirror["fetch"][0:4] == "git@":
|
||||||
|
cmd += ":"
|
||||||
|
else:
|
||||||
|
cmd += "/"
|
||||||
|
cmd += elem.name
|
||||||
ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||||
if ret != "" \
|
if ret != "" \
|
||||||
and ret != False:
|
and ret != False:
|
||||||
@@ -112,6 +125,10 @@ def execute(arguments):
|
|||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if just_download == True:
|
||||||
|
debug.info("SYNC: Already downloaded")
|
||||||
|
continue
|
||||||
|
|
||||||
if os.path.exists(os.path.join(git_repo_path,".git")) == False:
|
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
|
# 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")
|
debug.error("path '" + git_repo_path + "' is already existing but not used for a git repository. Clean it and restart")
|
||||||
|
@@ -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 " [" + self.dest_option + "]"
|
||||||
|
|
||||||
|
##
|
||||||
|
## @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] + " " + action_name + " " + listOfPropertiesArg + " ...")
|
||||||
for element in self.list_properties :
|
for element in self.list_properties :
|
||||||
element.display()
|
element.display()
|
||||||
|
|
||||||
|
@@ -26,6 +26,16 @@ def get_system_base_name():
|
|||||||
return system_base_name
|
return system_base_name
|
||||||
|
|
||||||
|
|
||||||
|
fetch_manifest = True
|
||||||
|
|
||||||
|
def set_fetch_manifest(val):
|
||||||
|
global fetch_manifest
|
||||||
|
fetch_manifest = val
|
||||||
|
|
||||||
|
def get_fetch_manifest():
|
||||||
|
global fetch_manifest
|
||||||
|
return fetch_manifest
|
||||||
|
|
||||||
|
|
||||||
island_root_path = os.path.join(os.getcwd())
|
island_root_path = os.path.join(os.getcwd())
|
||||||
if os.path.exists(os.path.join(island_root_path, "." + get_system_base_name())) == True:
|
if os.path.exists(os.path.join(island_root_path, "." + get_system_base_name())) == True:
|
||||||
@@ -37,12 +47,12 @@ elif os.path.exists(os.path.join(island_root_path, "..", "..", "." + get_system_
|
|||||||
island_root_path = os.path.join(os.getcwd(), "..", "..")
|
island_root_path = os.path.join(os.getcwd(), "..", "..")
|
||||||
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "." + get_system_base_name())) == True:
|
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "." + get_system_base_name())) == True:
|
||||||
island_root_path = os.path.join(os.getcwd(), "..", "..", "..")
|
island_root_path = os.path.join(os.getcwd(), "..", "..", "..")
|
||||||
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "." + get_system_base_name())) == True:
|
|
||||||
island_root_path = os.path.join(os.getcwd(), "..", "..", "..")
|
|
||||||
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "..", "." + get_system_base_name())) == True:
|
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "..", "." + get_system_base_name())) == True:
|
||||||
island_root_path = os.path.join(os.getcwd(), "..", "..", "..", "..")
|
island_root_path = os.path.join(os.getcwd(), "..", "..", "..", "..")
|
||||||
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "..", "..", "." + get_system_base_name())) == True:
|
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "..", "..", "." + get_system_base_name())) == True:
|
||||||
island_root_path = os.path.join(os.getcwd(), "..", "..", "..", "..", "..")
|
island_root_path = os.path.join(os.getcwd(), "..", "..", "..", "..", "..")
|
||||||
|
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "..", "..", "..", "." + get_system_base_name())) == True:
|
||||||
|
island_root_path = os.path.join(os.getcwd(), "..", "..", "..", "..", "..", "..")
|
||||||
else:
|
else:
|
||||||
#debug.error("the root path of " + get_system_base_name() + " must not be upper that 6 parent path")
|
#debug.error("the root path of " + get_system_base_name() + " must not be upper that 6 parent path")
|
||||||
pass
|
pass
|
||||||
|
@@ -78,7 +78,12 @@ class Manifest():
|
|||||||
and ( fetch[0] == "/" \
|
and ( fetch[0] == "/" \
|
||||||
or fetch[0] == "\\"):
|
or fetch[0] == "\\"):
|
||||||
fetch = fetch[1:]
|
fetch = fetch[1:]
|
||||||
base_origin = base_origin[:base_origin.rfind('/')]
|
offset_1 = base_origin.rfind('/')
|
||||||
|
offset_2 = base_origin.rfind(':')
|
||||||
|
if offset_1 > offset_2:
|
||||||
|
base_origin = base_origin[:offset_1]
|
||||||
|
else:
|
||||||
|
base_origin = base_origin[:offset_2]
|
||||||
debug.verbose("new base_origin=" + base_origin)
|
debug.verbose("new base_origin=" + base_origin)
|
||||||
debug.verbose("tmp fetch=" + fetch)
|
debug.verbose("tmp fetch=" + fetch)
|
||||||
if fetch != "":
|
if fetch != "":
|
||||||
|
8
setup.py
8
setup.py
@@ -16,7 +16,7 @@ def readme():
|
|||||||
|
|
||||||
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||||
setup(name='island',
|
setup(name='island',
|
||||||
version='0.4.0',
|
version='0.5.1',
|
||||||
description='island generic source manager (like repo in simple mode)',
|
description='island generic source manager (like repo in simple mode)',
|
||||||
long_description=readme(),
|
long_description=readme(),
|
||||||
url='http://github.com/HeeroYui/island',
|
url='http://github.com/HeeroYui/island',
|
||||||
@@ -45,5 +45,9 @@ setup(name='island',
|
|||||||
|
|
||||||
#To developp: sudo ./setup.py install
|
#To developp: sudo ./setup.py install
|
||||||
# sudo ./setup.py develop
|
# sudo ./setup.py develop
|
||||||
#TO register all in pip: ./setup.py register sdist upload
|
#TO register all in pip: use external tools:
|
||||||
|
# pip install twine
|
||||||
|
# # create the archive
|
||||||
|
# ./setup.py sdist
|
||||||
|
# twine upload dist/*
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user