Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
e4ce48df7c | |||
4b094dfcca | |||
020dc8f8de | |||
8d7fd32714 | |||
10f40f4d00 | |||
1a7129d632 | |||
49874b7785 | |||
6fda840ae5 | |||
7a46b3c0f9 | |||
bc556ee89b | |||
7f88a7cc34 | |||
9f11499b34 | |||
6da4400509 | |||
0f47c841fd | |||
bc82c533f1 | |||
f8de06c4d9 | |||
1d70339f72 | |||
e3a8d32557 | |||
e1a8280e01 | |||
a605da450f | |||
94f79962c4 | |||
9086c073a1 | |||
d362d47889 |
@@ -14,10 +14,11 @@ import copy
|
|||||||
# Local import
|
# Local import
|
||||||
from . import host
|
from . import host
|
||||||
from . import tools
|
from . import tools
|
||||||
from . import debug
|
from realog import debug
|
||||||
from . import env
|
from . import env
|
||||||
from . import actions
|
from . import actions
|
||||||
from . import arguments
|
import death.Arguments as arguments
|
||||||
|
import death.ArgElement as arg_element
|
||||||
is_init = False
|
is_init = False
|
||||||
|
|
||||||
|
|
||||||
@@ -54,35 +55,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.Arguments()
|
||||||
|
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 +130,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
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@@ -151,50 +154,47 @@ if os.path.isfile(config_file) == True:
|
|||||||
if "get_parsing_depth" in dir(configuration_file):
|
if "get_parsing_depth" in dir(configuration_file):
|
||||||
data = configuration_file.get_parsing_depth()
|
data = configuration_file.get_parsing_depth()
|
||||||
debug.debug(" get default config 'get_parsing_depth' val='" + str(data) + "'")
|
debug.debug(" get default config 'get_parsing_depth' val='" + str(data) + "'")
|
||||||
parseGenericArg(arguments.ArgElement("depth", str(data)), True)
|
parseGenericArg(arg_element.ArgElement("depth", str(data)), True)
|
||||||
|
|
||||||
if "get_default_jobs" in dir(configuration_file):
|
if "get_default_jobs" in dir(configuration_file):
|
||||||
data = configuration_file.get_default_jobs()
|
data = configuration_file.get_default_jobs()
|
||||||
debug.debug(" get default config 'get_default_jobs' val='" + str(data) + "'")
|
debug.debug(" get default config 'get_default_jobs' val='" + str(data) + "'")
|
||||||
parseGenericArg(arguments.ArgElement("jobs", str(data)), True)
|
parseGenericArg(arg_element.ArgElement("jobs", str(data)), True)
|
||||||
|
|
||||||
if "get_default_color" in dir(configuration_file):
|
if "get_default_color" in dir(configuration_file):
|
||||||
data = configuration_file.get_default_color()
|
data = configuration_file.get_default_color()
|
||||||
debug.debug(" get default config 'get_default_color' val='" + str(data) + "'")
|
debug.debug(" get default config 'get_default_color' val='" + str(data) + "'")
|
||||||
parseGenericArg(arguments.ArgElement("color", str(data)), True)
|
parseGenericArg(arg_element.ArgElement("color", str(data)), True)
|
||||||
|
|
||||||
if "get_default_debug_level" in dir(configuration_file):
|
if "get_default_debug_level" in dir(configuration_file):
|
||||||
data = configuration_file.get_default_debug_level()
|
data = configuration_file.get_default_debug_level()
|
||||||
debug.debug(" get default config 'get_default_debug_level' val='" + str(data) + "'")
|
debug.debug(" get default config 'get_default_debug_level' val='" + str(data) + "'")
|
||||||
parseGenericArg(arguments.ArgElement("verbose", str(data)), True)
|
parseGenericArg(arg_element.ArgElement("verbose", str(data)), True)
|
||||||
|
|
||||||
if "get_default_print_pretty" in dir(configuration_file):
|
if "get_default_print_pretty" in dir(configuration_file):
|
||||||
data = configuration_file.get_default_print_pretty()
|
data = configuration_file.get_default_print_pretty()
|
||||||
debug.debug(" get default config 'get_default_print_pretty' val='" + str(data) + "'")
|
debug.debug(" get default config 'get_default_print_pretty' val='" + str(data) + "'")
|
||||||
parseGenericArg(arguments.ArgElement("pretty", str(data)), True)
|
parseGenericArg(arg_element.ArgElement("pretty", str(data)), True)
|
||||||
|
|
||||||
if "get_default_force_optimisation" in dir(configuration_file):
|
if "get_default_force_optimisation" in dir(configuration_file):
|
||||||
data = configuration_file.get_default_force_optimisation()
|
data = configuration_file.get_default_force_optimisation()
|
||||||
debug.debug(" get default config 'get_default_force_optimisation' val='" + str(data) + "'")
|
debug.debug(" get default config 'get_default_force_optimisation' val='" + str(data) + "'")
|
||||||
parseGenericArg(arguments.ArgElement("force-optimisation", str(data)), True)
|
parseGenericArg(arg_element.ArgElement("force-optimisation", str(data)), True)
|
||||||
|
|
||||||
if "get_default_isolate_system" in dir(configuration_file):
|
if "get_default_isolate_system" in dir(configuration_file):
|
||||||
data = configuration_file.get_default_isolate_system()
|
data = configuration_file.get_default_isolate_system()
|
||||||
debug.debug(" get default config 'get_default_isolate_system' val='" + str(data) + "'")
|
debug.debug(" get default config 'get_default_isolate_system' val='" + str(data) + "'")
|
||||||
parseGenericArg(arguments.ArgElement("isolate-system", str(data)), True)
|
parseGenericArg(arg_element.ArgElement("isolate-system", str(data)), 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)
|
||||||
@@ -220,12 +220,12 @@ if action_to_do not in list_actions:
|
|||||||
|
|
||||||
# todo : Remove this
|
# todo : Remove this
|
||||||
if action_to_do != "init" \
|
if action_to_do != "init" \
|
||||||
and os.path.exists("." + env.get_system_base_name()) == False:
|
and os.path.exists(env.get_island_path()) == False:
|
||||||
debug.error("Can not execute a island cmd if we have not initialize a config: '" + str("." + env.get_system_base_name()) + "'")
|
debug.error("Can not execute a island cmd if we have not initialize a config: '" + str("." + env.get_system_base_name()) + "' in upper 6 parent path")
|
||||||
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()
|
||||||
|
@@ -9,10 +9,11 @@
|
|||||||
##
|
##
|
||||||
|
|
||||||
# Local import
|
# Local import
|
||||||
from . import debug
|
from realog import debug
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from . import env
|
from . import env
|
||||||
|
import death.Arguments as 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.Arguments()
|
||||||
|
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 "---"
|
||||||
|
@@ -8,9 +8,10 @@
|
|||||||
## @license MPL v2.0 (see license file)
|
## @license MPL v2.0 (see license file)
|
||||||
##
|
##
|
||||||
|
|
||||||
from island import debug
|
from realog import debug
|
||||||
from island import tools
|
from island import tools
|
||||||
from island import env
|
from island import env
|
||||||
|
from island import config
|
||||||
from island import multiprocess
|
from island import multiprocess
|
||||||
from island import manifest
|
from island import manifest
|
||||||
import os
|
import os
|
||||||
@@ -19,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() + "'")
|
||||||
@@ -44,9 +42,13 @@ def execute(arguments):
|
|||||||
or os.path.exists(env.get_island_path_manifest()) == 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()) + "'")
|
debug.error("System already init have an error: missing data: '" + str(env.get_island_path()) + "'")
|
||||||
|
|
||||||
configuration = manifest.load_config()
|
configuration = config.Config()
|
||||||
|
|
||||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration["file"])
|
# update the local configuration file:
|
||||||
|
configuration.set_branch(branch_to_checkout)
|
||||||
|
configuration.store()
|
||||||
|
|
||||||
|
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
if os.path.exists(file_source_manifest) == False:
|
if os.path.exists(file_source_manifest) == False:
|
||||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||||
|
|
||||||
@@ -89,11 +91,9 @@ def execute(arguments):
|
|||||||
list_branch2 = []
|
list_branch2 = []
|
||||||
select_branch = ""
|
select_branch = ""
|
||||||
for elem_branch in list_branch:
|
for elem_branch in list_branch:
|
||||||
|
list_branch2.append(elem_branch[2:])
|
||||||
if elem_branch[:2] == "* ":
|
if elem_branch[:2] == "* ":
|
||||||
list_branch2.append([elem_branch[2:], True])
|
|
||||||
select_branch = elem_branch[2:]
|
select_branch = elem_branch[2:]
|
||||||
else:
|
|
||||||
list_branch2.append([elem_branch[2:], False])
|
|
||||||
|
|
||||||
|
|
||||||
# check if we are on the good branch:
|
# check if we are on the good branch:
|
||||||
@@ -102,23 +102,36 @@ def execute(arguments):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
# check if we have already checkout the branch before
|
# check if we have already checkout the branch before
|
||||||
|
debug.verbose(" check : " + branch_to_checkout + " in " + str(list_branch2))
|
||||||
if branch_to_checkout in list_branch2:
|
if branch_to_checkout in list_branch2:
|
||||||
cmd = "git checkout " + branch_to_checkout
|
cmd = "git checkout " + branch_to_checkout
|
||||||
debug.verbose("execute : " + cmd)
|
debug.verbose("execute : " + cmd)
|
||||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||||
if ret[1] != "" \
|
if ret[0] != 0 \
|
||||||
|
and ret[1] != "" \
|
||||||
and ret != False:
|
and ret != False:
|
||||||
debug.info("'" + ret + "'")
|
debug.info("'" + str(ret) + "'")
|
||||||
debug.error("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> Can not checkout to the corest branch")
|
debug.error("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> Can not checkout to the correct branch")
|
||||||
continue
|
continue
|
||||||
debug.info("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> switch branch")
|
debug.info("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> switch branch")
|
||||||
# TODO : Check the number of commit to the origin/XXX branch ....
|
# TODO : Check the number of commit to the origin/XXX branch ....
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Check if the remote branch exist ...
|
||||||
# TODO: Check if the remote branch exist ...
|
cmd = "git branch -a"
|
||||||
|
debug.verbose("execute : " + cmd)
|
||||||
|
ret_branch_all = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||||
|
list_branch_all = ret_branch_all[1].split('\n')
|
||||||
|
exist = False
|
||||||
|
for elem_branch in list_branch_all:
|
||||||
|
debug.verbose(" check : '" + elem_branch + "' == '" + " remotes/" + elem.select_remote["name"] + "/" + branch_to_checkout + "'")
|
||||||
|
if elem_branch == " remotes/" + elem.select_remote["name"] + "/" + branch_to_checkout:
|
||||||
|
exist = True
|
||||||
|
debug.info(" ==> find ...")
|
||||||
|
break
|
||||||
|
if exist == False:
|
||||||
|
debug.info("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> NO remote branch")
|
||||||
|
continue
|
||||||
|
|
||||||
# checkout the new branch:
|
# checkout the new branch:
|
||||||
cmd = "git checkout --quiet " + elem.select_remote["name"] + "/" + branch_to_checkout + " -b " + branch_to_checkout
|
cmd = "git checkout --quiet " + elem.select_remote["name"] + "/" + branch_to_checkout + " -b " + branch_to_checkout
|
||||||
|
63
island/actions/islandAction_command.py
Normal file
63
island/actions/islandAction_command.py
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license MPL v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from realog import debug
|
||||||
|
from island import tools
|
||||||
|
from island import env
|
||||||
|
from island import multiprocess
|
||||||
|
from island import config
|
||||||
|
from island import manifest
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def help():
|
||||||
|
return "write the command you want to be executed in every repository"
|
||||||
|
|
||||||
|
def execute(arguments):
|
||||||
|
cmd = ""
|
||||||
|
for elem in arguments:
|
||||||
|
debug.info("Get data element: " + str(elem.get_arg()))
|
||||||
|
cmd += 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()
|
||||||
|
|
||||||
|
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("status of: " + str(len(all_project)) + " projects")
|
||||||
|
id_element = 0
|
||||||
|
for elem in all_project:
|
||||||
|
debug.info("------------------------------------------")
|
||||||
|
id_element += 1
|
||||||
|
debug.info("execute command : " + 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.info("" + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + "\r\t\t\t\t\t\t\t\t\t" + " (not download)")
|
||||||
|
continue
|
||||||
|
|
||||||
|
debug.verbose("execute : " + cmd)
|
||||||
|
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||||
|
if ret[0] == 0:
|
||||||
|
debug.info("ret=" + ret[1])
|
||||||
|
debug.info("err=" + ret[2])
|
||||||
|
else:
|
||||||
|
debug.info("Execution ERROR")
|
||||||
|
|
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 realog 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)
|
||||||
|
|
81
island/actions/islandAction_fetch.py
Normal file
81
island/actions/islandAction_fetch.py
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license MPL v2.0 (see license file)
|
||||||
|
##
|
||||||
|
|
||||||
|
from realog 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 "plop"
|
||||||
|
|
||||||
|
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("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
|
||||||
|
cmd = "git fetch"
|
||||||
|
if argument_remote_name != "":
|
||||||
|
cmd += " " + argument_remote_name
|
||||||
|
else:
|
||||||
|
cmd += " " + elem.select_remote["name"]
|
||||||
|
debug.verbose("execute : " + cmd)
|
||||||
|
multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||||
|
|
@@ -8,19 +8,22 @@
|
|||||||
## @license MPL v2.0 (see license file)
|
## @license MPL v2.0 (see license file)
|
||||||
##
|
##
|
||||||
|
|
||||||
from island import debug
|
from realog import debug
|
||||||
from island import tools
|
from island import tools
|
||||||
from island import env
|
from island import env
|
||||||
|
from island import config
|
||||||
from island import multiprocess
|
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 ...")
|
||||||
|
|
||||||
@@ -57,8 +60,11 @@ def execute(arguments):
|
|||||||
# check if the git of the manifest if availlable
|
# check if the git of the manifest if availlable
|
||||||
|
|
||||||
# create the file configuration:
|
# create the file configuration:
|
||||||
data = "repo=" + address_manifest + "\nbranch=" + branch + "\nfile=" + manifest_name
|
conf = config.Config()
|
||||||
tools.file_write_data(env.get_island_path_config(), data)
|
conf.set_manifest(address_manifest)
|
||||||
|
conf.set_branch(branch)
|
||||||
|
conf.set_manifest_name(manifest_name)
|
||||||
|
conf.store()
|
||||||
|
|
||||||
#clone the manifest repository
|
#clone the manifest repository
|
||||||
cmd = "git clone " + address_manifest + " --branch " + branch + " " + env.get_island_path_manifest()
|
cmd = "git clone " + address_manifest + " --branch " + branch + " " + env.get_island_path_manifest()
|
||||||
|
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 realog 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)
|
||||||
|
|
@@ -8,10 +8,11 @@
|
|||||||
## @license MPL v2.0 (see license file)
|
## @license MPL v2.0 (see license file)
|
||||||
##
|
##
|
||||||
|
|
||||||
from island import debug
|
from realog import debug
|
||||||
from island import tools
|
from island import tools
|
||||||
from island import env
|
from island import env
|
||||||
from island import multiprocess
|
from island import multiprocess
|
||||||
|
from island import config
|
||||||
from island import manifest
|
from island import manifest
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -20,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 \
|
||||||
@@ -36,9 +40,9 @@ def execute(arguments):
|
|||||||
or os.path.exists(env.get_island_path_manifest()) == 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()) + "'")
|
debug.error("System already init have an error: missing data: '" + str(env.get_island_path()) + "'")
|
||||||
|
|
||||||
configuration = manifest.load_config()
|
configuration = config.Config()
|
||||||
|
|
||||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration["file"])
|
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
if os.path.exists(file_source_manifest) == False:
|
if os.path.exists(file_source_manifest) == False:
|
||||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||||
|
|
||||||
@@ -61,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:
|
||||||
@@ -90,8 +108,33 @@ def execute(arguments):
|
|||||||
|
|
||||||
debug.verbose("select branch = '" + select_branch + "' is modify : " + str(is_modify) + " track: '" + str(ret_track[1]) + "'")
|
debug.verbose("select branch = '" + select_branch + "' is modify : " + str(is_modify) + " track: '" + str(ret_track[1]) + "'")
|
||||||
|
|
||||||
|
cmd = "git rev-list " + select_branch
|
||||||
|
debug.verbose("execute : " + cmd)
|
||||||
|
ret_current_branch_sha1 = multiprocess.run_command(cmd, cwd=git_repo_path)[1].split('\n')
|
||||||
|
cmd = "git rev-list " + ret_track[1]
|
||||||
|
debug.verbose("execute : " + cmd)
|
||||||
|
ret_track_branch_sha1 = multiprocess.run_command(cmd, cwd=git_repo_path)[1].split('\n')
|
||||||
|
# remove all identical sha1 ==> not needed for this
|
||||||
|
in_forward = 0
|
||||||
|
for elem_sha1 in ret_current_branch_sha1:
|
||||||
|
if elem_sha1 not in ret_track_branch_sha1:
|
||||||
|
in_forward += 1
|
||||||
|
in_behind = 0
|
||||||
|
for elem_sha1 in ret_track_branch_sha1:
|
||||||
|
if elem_sha1 not in ret_current_branch_sha1:
|
||||||
|
in_behind += 1
|
||||||
|
|
||||||
|
behind_forward_comment = ""
|
||||||
|
if in_forward != 0:
|
||||||
|
behind_forward_comment += "forward=" + str(in_forward)
|
||||||
|
if in_behind != 0:
|
||||||
|
if in_forward != 0:
|
||||||
|
behind_forward_comment += " "
|
||||||
|
behind_forward_comment += "behind=" + str(in_behind)
|
||||||
|
if behind_forward_comment != "":
|
||||||
|
behind_forward_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t[" + behind_forward_comment + "]"
|
||||||
#debug.info("" + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + "\r\t\t\t\t\t\t\t" + modify_status + "(" + select_branch + " -> " + ret_track[1] + " -> " + elem.select_remote["name"] + "/" + elem.branch + ")")
|
#debug.info("" + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + "\r\t\t\t\t\t\t\t" + modify_status + "(" + select_branch + " -> " + ret_track[1] + " -> " + elem.select_remote["name"] + "/" + elem.branch + ")")
|
||||||
debug.info("" + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + "\r\t\t\t\t\t\t\t" + modify_status + "(" + select_branch + " -> " + ret_track[1] + ")")
|
debug.info("" + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + "\r\t\t\t\t\t\t\t" + modify_status + "(" + select_branch + " -> " + ret_track[1] + ")" + behind_forward_comment)
|
||||||
if is_modify == True:
|
if is_modify == True:
|
||||||
cmd = "git status --short"
|
cmd = "git status --short"
|
||||||
debug.verbose("execute : " + cmd)
|
debug.verbose("execute : " + cmd)
|
||||||
|
@@ -8,9 +8,10 @@
|
|||||||
## @license MPL v2.0 (see license file)
|
## @license MPL v2.0 (see license file)
|
||||||
##
|
##
|
||||||
|
|
||||||
from island import debug
|
from realog import debug
|
||||||
from island import tools
|
from island import tools
|
||||||
from island import env
|
from island import env
|
||||||
|
from island import config
|
||||||
from island import multiprocess
|
from island import multiprocess
|
||||||
from island import manifest
|
from island import manifest
|
||||||
import os
|
import os
|
||||||
@@ -20,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 \
|
||||||
@@ -37,14 +40,14 @@ def execute(arguments):
|
|||||||
debug.error("System already init have an error: missing data: '" + str(env.get_island_path()) + "'")
|
debug.error("System already init have an error: missing data: '" + str(env.get_island_path()) + "'")
|
||||||
|
|
||||||
|
|
||||||
configuration = manifest.load_config()
|
configuration = config.Config()
|
||||||
|
|
||||||
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"
|
||||||
multiprocess.run_command_direct(cmd, cwd=env.get_island_path_manifest())
|
multiprocess.run_command_direct(cmd, cwd=env.get_island_path_manifest())
|
||||||
|
|
||||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration["file"])
|
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||||
if os.path.exists(file_source_manifest) == False:
|
if os.path.exists(file_source_manifest) == False:
|
||||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||||
|
|
||||||
@@ -62,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 != "" \
|
||||||
@@ -75,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:
|
||||||
@@ -111,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")
|
||||||
@@ -118,6 +136,7 @@ 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 " + 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)
|
||||||
@@ -153,12 +172,26 @@ def execute(arguments):
|
|||||||
if is_modify == True:
|
if is_modify == True:
|
||||||
debug.warning("[" + elem.name + "] Not update ==> the repository is modified")
|
debug.warning("[" + elem.name + "] Not update ==> the repository is modified")
|
||||||
continue
|
continue
|
||||||
|
""" # TODO: this does not work ...
|
||||||
if ret_track[1] != elem.select_remote["name"] + "/" + elem.branch:
|
if ret_track[1] != elem.select_remote["name"] + "/" + elem.branch:
|
||||||
debug.warning("[" + elem.name + "] Not update ==> the current branch does not track the correct branch : track '" + ret_track[1] + "' instead of '" + elem.select_remote["name"] + "/" + elem.branch + "'")
|
debug.warning("[" + elem.name + "] Not update ==> the current branch does not track the correct branch : track '" + ret_track[1] + "' instead of '" + elem.select_remote["name"] + "/" + elem.branch + "'")
|
||||||
continue
|
continue
|
||||||
|
"""
|
||||||
|
cmd = "git pull"
|
||||||
|
debug.verbose("execute : " + cmd)
|
||||||
|
ret_pull = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||||
|
if ret_pull[0] == 0:
|
||||||
|
if ret_pull[1] == "Already up-to-date.":
|
||||||
|
pass
|
||||||
|
elif ret_pull[1] != "":
|
||||||
|
debug.info(ret_pull[1])
|
||||||
|
else:
|
||||||
|
if ret_pull[1] != "":
|
||||||
|
debug.warning("ERROR GIT: " + ret_pull[1])
|
||||||
|
else:
|
||||||
|
debug.warning("ERROR GIT: in pull")
|
||||||
|
|
||||||
debug.info("select branch = '" + select_branch + "' is modify : " + str(is_modify) + " track: '" + str(ret_track[1]) + "'")
|
debug.verbose("select branch = '" + select_branch + "' is modify : " + str(is_modify) + " track: '" + str(ret_track[1]) + "'")
|
||||||
# check submodule if requested:
|
# check submodule if requested:
|
||||||
if elem.select_remote["sync"] == True \
|
if elem.select_remote["sync"] == True \
|
||||||
and os.path.exists(os.path.join(git_repo_path, ".gitmodules")) == True:
|
and os.path.exists(os.path.join(git_repo_path, ".gitmodules")) == True:
|
||||||
|
@@ -1,378 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
##
|
|
||||||
## @author Edouard DUPIN
|
|
||||||
##
|
|
||||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
|
||||||
##
|
|
||||||
## @license MPL v2.0 (see license file)
|
|
||||||
##
|
|
||||||
import sys
|
|
||||||
from . import debug
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Single argument class. It permit to define the getted argument.
|
|
||||||
##
|
|
||||||
class ArgElement:
|
|
||||||
##
|
|
||||||
## @brief Contructor.
|
|
||||||
## @param[in] self Class handle
|
|
||||||
## @param[in] option (string) Option name (write in fullmode ex: '--verbose' even if user write '-v')
|
|
||||||
## @param[in] value (string) Writed value by the user (defult '')
|
|
||||||
##
|
|
||||||
def __init__(self, option, value=""):
|
|
||||||
self.option = option;
|
|
||||||
self.arg = value;
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Get the name of the argument: (write in fullmode ex: '--verbose' even if user write '-v')
|
|
||||||
## @param[in] self Class handle
|
|
||||||
## @return (string) The argument name
|
|
||||||
##
|
|
||||||
def get_option_name(self):
|
|
||||||
return self.option
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Get argument data set by the user
|
|
||||||
## @param[in] self Class handle
|
|
||||||
## @return (string) The argument value
|
|
||||||
##
|
|
||||||
def get_arg(self):
|
|
||||||
return self.arg
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Display the Argument property
|
|
||||||
## @param[in] self Class handle
|
|
||||||
##
|
|
||||||
def display(self):
|
|
||||||
if len(self.arg) == 0:
|
|
||||||
debug.info("option : " + self.option)
|
|
||||||
elif len(self.option) == 0:
|
|
||||||
debug.info("element : " + self.arg)
|
|
||||||
else:
|
|
||||||
debug.info("option : " + self.option + ":" + self.arg)
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Declare a possibility of an argument value
|
|
||||||
##
|
|
||||||
class ArgDefine:
|
|
||||||
##
|
|
||||||
## @brief Contructor.
|
|
||||||
## @param[in] self Class handle
|
|
||||||
## @param[in] smallOption (char) Value for the small option ex: '-v' '-k' ... 1 single char element (no need of '-')
|
|
||||||
## @param[in] bigOption (string) Value of the big option name ex: '--verbose' '--kill' ... stated with -- and with the full name (no need of '--')
|
|
||||||
## @param[in] list ([[string,string],...]) Optionnal list of availlable option: '--mode=debug' ==> [['debug', 'debug mode'],['release', 'release the software']]
|
|
||||||
## @param[in] desc (string) user friendly description with this parameter (default "")
|
|
||||||
## @param[in] haveParam (bool) The option must have a parameter (default False)
|
|
||||||
##
|
|
||||||
def __init__(self,
|
|
||||||
smallOption="", # like v for -v
|
|
||||||
bigOption="", # like verbose for --verbose
|
|
||||||
list=[], # ["val", "description"]
|
|
||||||
desc="",
|
|
||||||
haveParam=False):
|
|
||||||
self.option_small = smallOption;
|
|
||||||
self.option_big = bigOption;
|
|
||||||
self.list = list;
|
|
||||||
if len(self.list)!=0:
|
|
||||||
self.have_param = True
|
|
||||||
else:
|
|
||||||
if True==haveParam:
|
|
||||||
self.have_param = True
|
|
||||||
else:
|
|
||||||
self.have_param = False
|
|
||||||
self.description = desc;
|
|
||||||
|
|
||||||
##
|
|
||||||
## @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 self.option_small
|
|
||||||
|
|
||||||
##
|
|
||||||
## @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.option_big
|
|
||||||
|
|
||||||
##
|
|
||||||
## @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):
|
|
||||||
return self.have_param
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Compatibility with @ref ArgSection class
|
|
||||||
## @param[in] self Class handle
|
|
||||||
## @return (string) empty string
|
|
||||||
##
|
|
||||||
def get_porperties(self):
|
|
||||||
return ""
|
|
||||||
|
|
||||||
##
|
|
||||||
## @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):
|
|
||||||
if len(self.list)==0:
|
|
||||||
return True
|
|
||||||
for element,desc in self.list:
|
|
||||||
if element == argument:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Display the argument property when user request help
|
|
||||||
## @param[in] self Class handle
|
|
||||||
##
|
|
||||||
def display(self):
|
|
||||||
color = debug.get_color_set()
|
|
||||||
if self.option_small != "" and self.option_big != "":
|
|
||||||
print(" " + color['red'] + "-" + self.option_small + "" + color['default'] + " / " + color['red'] + "--" + self.option_big + color['default'])
|
|
||||||
elif self.option_small != "":
|
|
||||||
print(" " + color['red'] + "-" + self.option_small + color['default'])
|
|
||||||
elif self.option_big != "":
|
|
||||||
print(" " + color['red'] + "--" + self.option_big + color['default'])
|
|
||||||
else:
|
|
||||||
print(" ???? ==> internal error ...")
|
|
||||||
if self.description != "":
|
|
||||||
print(" " + self.description)
|
|
||||||
if len(self.list)!=0:
|
|
||||||
hasDescriptiveElement=False
|
|
||||||
for val,desc in self.list:
|
|
||||||
if desc!="":
|
|
||||||
hasDescriptiveElement=True
|
|
||||||
break;
|
|
||||||
if hasDescriptiveElement==True:
|
|
||||||
for val,desc in self.list:
|
|
||||||
print(" " + val + " : " + desc)
|
|
||||||
else:
|
|
||||||
tmpElementPrint = ""
|
|
||||||
for val,desc in self.list:
|
|
||||||
if len(tmpElementPrint)!=0:
|
|
||||||
tmpElementPrint += " / "
|
|
||||||
tmpElementPrint += val
|
|
||||||
print(" { " + tmpElementPrint + " }")
|
|
||||||
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Section Class definition (permit to add a comment when requesting help
|
|
||||||
##
|
|
||||||
class ArgSection:
|
|
||||||
##
|
|
||||||
## @brief Constructor
|
|
||||||
## @param[in] self Class handle
|
|
||||||
## @param[in] sectionName (string) Name of the cestion ex: "option" is displayed [option]
|
|
||||||
## @param[in] desc (string) Comment assiciated with the group
|
|
||||||
##
|
|
||||||
def __init__(self,
|
|
||||||
sectionName="",
|
|
||||||
desc=""):
|
|
||||||
self.section = sectionName;
|
|
||||||
self.description = desc;
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Compatibility with @ref ArgDefine class
|
|
||||||
## @param[in] self Class handle
|
|
||||||
## @return empty string
|
|
||||||
##
|
|
||||||
def get_option_small(self):
|
|
||||||
return ""
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Compatibility with @ref ArgDefine class
|
|
||||||
## @param[in] self Class handle
|
|
||||||
## @return empty string
|
|
||||||
##
|
|
||||||
def get_option_big(self):
|
|
||||||
return ""
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief get property print value with the correct writing mode
|
|
||||||
## @param[in] self Class handle
|
|
||||||
## @return String to display in the short line help
|
|
||||||
##
|
|
||||||
def get_porperties(self):
|
|
||||||
color = debug.get_color_set()
|
|
||||||
return " [" + color['blue'] + self.section + color['default'] + "]"
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Display the argument property when user request help
|
|
||||||
## @param[in] self Class handle
|
|
||||||
##
|
|
||||||
def display(self):
|
|
||||||
color = debug.get_color_set()
|
|
||||||
print(" [" + color['blue'] + self.section + color['default'] + "] : " + self.description)
|
|
||||||
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Class to define the agmument list availlable for a program
|
|
||||||
##
|
|
||||||
class islandArg:
|
|
||||||
##
|
|
||||||
## @brief Constructor.
|
|
||||||
## @param[in] self Class handle
|
|
||||||
##
|
|
||||||
def __init__(self):
|
|
||||||
self.list_properties = []
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Add a new argument possibilities...
|
|
||||||
## @param[in] self Class handle
|
|
||||||
## @param[in] smallOption (char) Value for the small option ex: '-v' '-k' ... 1 single char element (no need of '-')
|
|
||||||
## @param[in] bigOption (string) Value of the big option name ex: '--verbose' '--kill' ... stated with -- and with the full name (no need of '--')
|
|
||||||
## @param[in] list ([[string,string],...]) Optionnal list of availlable option: '--mode=debug' ==> [['debug', 'debug mode'],['release', 'release the software']]
|
|
||||||
## @param[in] desc (string) user friendly description with this parameter (default "")
|
|
||||||
## @param[in] haveParam (bool) The option must have a parameter (default False)
|
|
||||||
##
|
|
||||||
def add(self, smallOption="", bigOption="", list=[], desc="", haveParam=False):
|
|
||||||
self.list_properties.append(ArgDefine(smallOption, bigOption, list, desc, haveParam))
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Add section on argument list
|
|
||||||
## @param[in] self Class handle
|
|
||||||
## @param[in] sectionName (string) Name of the cestion ex: "option" is displayed [option]
|
|
||||||
## @param[in] sectionDesc (string) Comment assiciated with the group
|
|
||||||
##
|
|
||||||
def add_section(self, sectionName, sectionDesc):
|
|
||||||
self.list_properties.append(ArgSection(sectionName, sectionDesc))
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Parse the argument set in the command line
|
|
||||||
## @param[in] self Class handle
|
|
||||||
##
|
|
||||||
def parse(self):
|
|
||||||
listArgument = [] # composed of list element
|
|
||||||
NotparseNextElement=False
|
|
||||||
for iii in range(1, len(sys.argv)):
|
|
||||||
# special case of parameter in some elements
|
|
||||||
if NotparseNextElement==True:
|
|
||||||
NotparseNextElement = False
|
|
||||||
continue
|
|
||||||
debug.verbose("parse [" + str(iii) + "]=" + sys.argv[iii])
|
|
||||||
argument = sys.argv[iii]
|
|
||||||
optionList = argument.split("=")
|
|
||||||
debug.verbose(str(optionList))
|
|
||||||
if type(optionList) == type(str()):
|
|
||||||
option = optionList
|
|
||||||
else:
|
|
||||||
option = optionList[0]
|
|
||||||
optionParam = argument[len(option)+1:]
|
|
||||||
debug.verbose(option)
|
|
||||||
argumentFound=False;
|
|
||||||
if option[:2]=="--":
|
|
||||||
# big argument
|
|
||||||
for prop in self.list_properties:
|
|
||||||
if prop.get_option_big()=="":
|
|
||||||
continue
|
|
||||||
if prop.get_option_big() == option[2:]:
|
|
||||||
# find it
|
|
||||||
debug.verbose("find argument 2 : " + option[2:])
|
|
||||||
if prop.need_parameters()==True:
|
|
||||||
internalSub = option[2+len(prop.get_option_big()):]
|
|
||||||
if len(internalSub)!=0:
|
|
||||||
if len(optionParam)!=0:
|
|
||||||
# wrong argument ...
|
|
||||||
debug.warning("maybe wrong argument for : '" + prop.get_option_big() + "' cmdLine='" + argument + "'")
|
|
||||||
prop.display()
|
|
||||||
continue
|
|
||||||
optionParam = internalSub
|
|
||||||
if len(optionParam)==0:
|
|
||||||
#Get the next parameters
|
|
||||||
if len(sys.argv) > iii+1:
|
|
||||||
optionParam = sys.argv[iii+1]
|
|
||||||
NotparseNextElement=True
|
|
||||||
else :
|
|
||||||
# missing arguments
|
|
||||||
debug.warning("parsing argument error : '" + prop.get_option_big() + "' Missing : subParameters ... cmdLine='" + argument + "'")
|
|
||||||
prop.display()
|
|
||||||
exit(-1)
|
|
||||||
if prop.check_availlable(optionParam)==False:
|
|
||||||
debug.warning("argument error : '" + prop.get_option_big() + "' SubParameters not availlable ... cmdLine='" + argument + "' option='" + optionParam + "'")
|
|
||||||
prop.display()
|
|
||||||
exit(-1)
|
|
||||||
listArgument.append(ArgElement(prop.get_option_big(),optionParam))
|
|
||||||
argumentFound = True
|
|
||||||
else:
|
|
||||||
if len(optionParam)!=0:
|
|
||||||
debug.warning("parsing argument error : '" + prop.get_option_big() + "' need no subParameters : '" + optionParam + "' cmdLine='" + argument + "'")
|
|
||||||
prop.display()
|
|
||||||
listArgument.append(ArgElement(prop.get_option_big()))
|
|
||||||
argumentFound = True
|
|
||||||
break;
|
|
||||||
if False==argumentFound:
|
|
||||||
debug.error("UNKNOW argument : '" + argument + "'")
|
|
||||||
elif option[:1]=="-":
|
|
||||||
# small argument
|
|
||||||
for prop in self.list_properties:
|
|
||||||
if prop.get_option_small()=="":
|
|
||||||
continue
|
|
||||||
if prop.get_option_small() == option[1:1+len(prop.get_option_small())]:
|
|
||||||
# find it
|
|
||||||
debug.verbose("find argument 1 : " + option[1:1+len(prop.get_option_small())])
|
|
||||||
if prop.need_parameters()==True:
|
|
||||||
internalSub = option[1+len(prop.get_option_small()):]
|
|
||||||
if len(internalSub)!=0:
|
|
||||||
if len(optionParam)!=0:
|
|
||||||
# wrong argument ...
|
|
||||||
debug.warning("maybe wrong argument for : '" + prop.get_option_big() + "' cmdLine='" + argument + "'")
|
|
||||||
prop.display()
|
|
||||||
continue
|
|
||||||
optionParam = internalSub
|
|
||||||
if len(optionParam)==0:
|
|
||||||
#Get the next parameters
|
|
||||||
if len(sys.argv) > iii+1:
|
|
||||||
optionParam = sys.argv[iii+1]
|
|
||||||
NotparseNextElement=True
|
|
||||||
else :
|
|
||||||
# missing arguments
|
|
||||||
debug.warning("parsing argument error : '" + prop.get_option_big() + "' Missing : subParameters cmdLine='" + argument + "'")
|
|
||||||
prop.display()
|
|
||||||
exit(-1)
|
|
||||||
if prop.check_availlable(optionParam)==False:
|
|
||||||
debug.warning("argument error : '" + prop.get_option_big() + "' SubParameters not availlable ... cmdLine='" + argument + "' option='" + optionParam + "'")
|
|
||||||
prop.display()
|
|
||||||
exit(-1)
|
|
||||||
listArgument.append(ArgElement(prop.get_option_big(),optionParam))
|
|
||||||
argumentFound = True
|
|
||||||
else:
|
|
||||||
if len(optionParam)!=0:
|
|
||||||
debug.warning("parsing argument error : '" + prop.get_option_big() + "' need no subParameters : '" + optionParam + "' cmdLine='" + argument + "'")
|
|
||||||
prop.display()
|
|
||||||
listArgument.append(ArgElement(prop.get_option_big()))
|
|
||||||
argumentFound = True
|
|
||||||
break;
|
|
||||||
|
|
||||||
if argumentFound==False:
|
|
||||||
#unknow element ... ==> just add in the list ...
|
|
||||||
debug.verbose("unknow argument : " + argument)
|
|
||||||
listArgument.append(ArgElement("", argument))
|
|
||||||
|
|
||||||
#for argument in listArgument:
|
|
||||||
# argument.display()
|
|
||||||
#exit(0)
|
|
||||||
return listArgument;
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Display help on console output
|
|
||||||
## @param[in] self Class handle
|
|
||||||
##
|
|
||||||
def display(self):
|
|
||||||
print("usage:")
|
|
||||||
listOfPropertiesArg = "";
|
|
||||||
for element in self.list_properties :
|
|
||||||
listOfPropertiesArg += element.get_porperties()
|
|
||||||
print(" " + sys.argv[0] + listOfPropertiesArg + " ...")
|
|
||||||
for element in self.list_properties :
|
|
||||||
element.display()
|
|
||||||
|
|
72
island/config.py
Normal file
72
island/config.py
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
##
|
||||||
|
## @author Edouard DUPIN
|
||||||
|
##
|
||||||
|
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||||
|
##
|
||||||
|
## @license MPL v2.0 (see license file)
|
||||||
|
##
|
||||||
|
import platform
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import copy
|
||||||
|
# Local import
|
||||||
|
from realog import debug
|
||||||
|
from . import tools
|
||||||
|
from . import env
|
||||||
|
from . import multiprocess
|
||||||
|
|
||||||
|
|
||||||
|
env.get_island_path_config()
|
||||||
|
|
||||||
|
|
||||||
|
class Config():
|
||||||
|
def __init__(self):
|
||||||
|
self._repo = ""
|
||||||
|
self._branch = "master"
|
||||||
|
self._manifest_name = "default.xml"
|
||||||
|
|
||||||
|
self.load()
|
||||||
|
|
||||||
|
|
||||||
|
def load(self):
|
||||||
|
config_property = tools.file_read_data(env.get_island_path_config())
|
||||||
|
element_config = config_property.split("\n")
|
||||||
|
for line in element_config:
|
||||||
|
if len(line) == 0 \
|
||||||
|
or line[0] == "#":
|
||||||
|
# simple comment line ==> pass
|
||||||
|
pass
|
||||||
|
elif line[:5] == "repo=":
|
||||||
|
self._repo = line[5:]
|
||||||
|
elif line[:7] == "branch=":
|
||||||
|
self._branch = line[7:]
|
||||||
|
elif line[:5] == "file=":
|
||||||
|
self._manifest_name = line[5:]
|
||||||
|
else:
|
||||||
|
debug.warning("island config error: can not parse: '" + str(line) + "'")
|
||||||
|
return True
|
||||||
|
|
||||||
|
def store(self):
|
||||||
|
data = "repo=" + self._repo + "\nbranch=" + self._branch + "\nfile=" + self._manifest_name
|
||||||
|
tools.file_write_data(env.get_island_path_config(), data)
|
||||||
|
|
||||||
|
def set_manifest(self, value):
|
||||||
|
self._repo = value
|
||||||
|
|
||||||
|
def get_manifest(self):
|
||||||
|
return self._repo
|
||||||
|
|
||||||
|
def set_branch(self, value):
|
||||||
|
self._branch = value
|
||||||
|
|
||||||
|
def get_branch(self):
|
||||||
|
return self._branch
|
||||||
|
|
||||||
|
def set_manifest_name(self, value):
|
||||||
|
self._manifest_name = value
|
||||||
|
|
||||||
|
def get_manifest_name(self):
|
||||||
|
return self._manifest_name
|
||||||
|
|
258
island/debug.py
258
island/debug.py
@@ -1,258 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
##
|
|
||||||
## @author Edouard DUPIN
|
|
||||||
##
|
|
||||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
|
||||||
##
|
|
||||||
## @license MPL v2.0 (see license file)
|
|
||||||
##
|
|
||||||
|
|
||||||
import os
|
|
||||||
import threading
|
|
||||||
import re
|
|
||||||
|
|
||||||
debug_level=3
|
|
||||||
debug_color=False
|
|
||||||
|
|
||||||
color_default= ""
|
|
||||||
color_red = ""
|
|
||||||
color_green = ""
|
|
||||||
color_yellow = ""
|
|
||||||
color_blue = ""
|
|
||||||
color_purple = ""
|
|
||||||
color_cyan = ""
|
|
||||||
|
|
||||||
|
|
||||||
debug_lock = threading.Lock()
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Set log level of the console log system
|
|
||||||
## @param[in] id (int) Value of the log level:
|
|
||||||
## 0: None
|
|
||||||
## 1: error
|
|
||||||
## 2: warning
|
|
||||||
## 3: info
|
|
||||||
## 4: debug
|
|
||||||
## 5: verbose
|
|
||||||
## 6: extreme_verbose
|
|
||||||
##
|
|
||||||
def set_level(id):
|
|
||||||
global debug_level
|
|
||||||
debug_level = id
|
|
||||||
#print "SetDebug level at " + str(debug_level)
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Get the current debug leval
|
|
||||||
## @return The value of the log level. Show: @ref set_level
|
|
||||||
##
|
|
||||||
def get_level():
|
|
||||||
global debug_level
|
|
||||||
return debug_level
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Enable color of the console Log system
|
|
||||||
##
|
|
||||||
def enable_color():
|
|
||||||
global debug_color
|
|
||||||
debug_color = True
|
|
||||||
global color_default
|
|
||||||
color_default= "\033[00m"
|
|
||||||
global color_red
|
|
||||||
color_red = "\033[31m"
|
|
||||||
global color_green
|
|
||||||
color_green = "\033[32m"
|
|
||||||
global color_yellow
|
|
||||||
color_yellow = "\033[33m"
|
|
||||||
global color_blue
|
|
||||||
color_blue = "\033[01;34m"
|
|
||||||
global color_purple
|
|
||||||
color_purple = "\033[35m"
|
|
||||||
global color_cyan
|
|
||||||
color_cyan = "\033[36m"
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Disable color of the console Log system
|
|
||||||
##
|
|
||||||
def disable_color():
|
|
||||||
global debug_color
|
|
||||||
debug_color = True
|
|
||||||
global color_default
|
|
||||||
color_default= ""
|
|
||||||
global color_red
|
|
||||||
color_red = ""
|
|
||||||
global color_green
|
|
||||||
color_green = ""
|
|
||||||
global color_yellow
|
|
||||||
color_yellow = ""
|
|
||||||
global color_blue
|
|
||||||
color_blue = ""
|
|
||||||
global color_purple
|
|
||||||
color_purple = ""
|
|
||||||
global color_cyan
|
|
||||||
color_cyan = ""
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Print a extreme verbose log
|
|
||||||
## @param[in] input (string) Value to print if level is enough
|
|
||||||
## @param[in] force (bool) force display (no check of log level)
|
|
||||||
##
|
|
||||||
def extreme_verbose(input, force=False):
|
|
||||||
global debug_lock
|
|
||||||
global debug_level
|
|
||||||
if debug_level >= 6 \
|
|
||||||
or force == True:
|
|
||||||
debug_lock.acquire()
|
|
||||||
print(color_blue + input + color_default)
|
|
||||||
debug_lock.release()
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Print a verbose log
|
|
||||||
## @param[in] input (string) Value to print if level is enough
|
|
||||||
## @param[in] force (bool) force display (no check of log level)
|
|
||||||
##
|
|
||||||
def verbose(input, force=False):
|
|
||||||
global debug_lock
|
|
||||||
global debug_level
|
|
||||||
if debug_level >= 5 \
|
|
||||||
or force == True:
|
|
||||||
debug_lock.acquire()
|
|
||||||
print(color_blue + input + color_default)
|
|
||||||
debug_lock.release()
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Print a debug log
|
|
||||||
## @param[in] input (string) Value to print if level is enough
|
|
||||||
## @param[in] force (bool) force display (no check of log level)
|
|
||||||
##
|
|
||||||
def debug(input, force=False):
|
|
||||||
global debug_lock
|
|
||||||
global debug_level
|
|
||||||
if debug_level >= 4 \
|
|
||||||
or force == True:
|
|
||||||
debug_lock.acquire()
|
|
||||||
print(color_green + input + color_default)
|
|
||||||
debug_lock.release()
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Print an info log
|
|
||||||
## @param[in] input (string) Value to print if level is enough
|
|
||||||
## @param[in] force (bool) force display (no check of log level)
|
|
||||||
##
|
|
||||||
def info(input, force=False):
|
|
||||||
global debug_lock
|
|
||||||
global debug_level
|
|
||||||
if debug_level >= 3 \
|
|
||||||
or force == True:
|
|
||||||
debug_lock.acquire()
|
|
||||||
print(input + color_default)
|
|
||||||
debug_lock.release()
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Print a warning log
|
|
||||||
## @param[in] input (string) Value to print if level is enough
|
|
||||||
## @param[in] force (bool) force display (no check of log level)
|
|
||||||
##
|
|
||||||
def warning(input, force=False):
|
|
||||||
global debug_lock
|
|
||||||
global debug_level
|
|
||||||
if debug_level >= 2 \
|
|
||||||
or force == True:
|
|
||||||
debug_lock.acquire()
|
|
||||||
print(color_purple + "[WARNING] " + input + color_default)
|
|
||||||
debug_lock.release()
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Print a todo log
|
|
||||||
## @param[in] input (string) Value to print if level is enough
|
|
||||||
## @param[in] force (bool) force display (no check of log level)
|
|
||||||
##
|
|
||||||
def todo(input, force=False):
|
|
||||||
global debug_lock
|
|
||||||
global debug_level
|
|
||||||
if debug_level >= 3 \
|
|
||||||
or force == True:
|
|
||||||
debug_lock.acquire()
|
|
||||||
print(color_purple + "[TODO] " + input + color_default)
|
|
||||||
debug_lock.release()
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Print an error log
|
|
||||||
## @param[in] input (string) Value to print if level is enough
|
|
||||||
## @param[in] thread_id (int) Current thead ID of the builder thread
|
|
||||||
## @param[in] force (bool) force display (no check of log level)
|
|
||||||
## @param[in] crash (bool) build error has appear ==> request stop of all builds
|
|
||||||
##
|
|
||||||
def error(input, thread_id=-1, force=False, crash=True):
|
|
||||||
global debug_lock
|
|
||||||
global debug_level
|
|
||||||
if debug_level >= 1 \
|
|
||||||
or force == True:
|
|
||||||
debug_lock.acquire()
|
|
||||||
print(color_red + "[ERROR] " + input + color_default)
|
|
||||||
debug_lock.release()
|
|
||||||
if crash == True:
|
|
||||||
exit(-1)
|
|
||||||
#os_exit(-1)
|
|
||||||
#raise "error happend"
|
|
||||||
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Print a log for a specific element action like generateing .so or binary ...
|
|
||||||
## @param[in] type (string) type of action. Like: "copy file", "StaticLib", "Prebuild", "Library" ...
|
|
||||||
## @param[in] lib (string) Name of the library/binary/package that action is done
|
|
||||||
## @param[in] dir (string) build direction. ex: "<==", "==>" ...
|
|
||||||
## @param[in] name (string) Destination of the data
|
|
||||||
## @param[in] force (bool) force display (no check of log level)
|
|
||||||
##
|
|
||||||
def print_element(type, lib, dir, name, force=False):
|
|
||||||
global debug_lock
|
|
||||||
global debug_level
|
|
||||||
if debug_level >= 3 \
|
|
||||||
or force == True:
|
|
||||||
debug_lock.acquire()
|
|
||||||
print(color_cyan + type + color_default + " : " + color_yellow + lib + color_default + " " + dir + " " + color_blue + name + color_default)
|
|
||||||
debug_lock.release()
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Print a compilation return (output)
|
|
||||||
## @param[in] my_string (string) Std-error/std-info that is generate by the build system
|
|
||||||
##
|
|
||||||
def print_compilator(my_string):
|
|
||||||
global debug_color
|
|
||||||
global debug_lock
|
|
||||||
if debug_color == True:
|
|
||||||
my_string = my_string.replace('\\n', '\n')
|
|
||||||
my_string = my_string.replace('\\t', '\t')
|
|
||||||
my_string = my_string.replace('error:', color_red+'error:'+color_default)
|
|
||||||
my_string = my_string.replace('warning:', color_purple+'warning:'+color_default)
|
|
||||||
my_string = my_string.replace('note:', color_green+'note:'+color_default)
|
|
||||||
my_string = re.sub(r'([/\w_-]+\.\w+):', r'-COLORIN-\1-COLOROUT-:', my_string)
|
|
||||||
my_string = my_string.replace('-COLORIN-', color_yellow)
|
|
||||||
my_string = my_string.replace('-COLOROUT-', color_default)
|
|
||||||
|
|
||||||
debug_lock.acquire()
|
|
||||||
print(my_string)
|
|
||||||
debug_lock.release()
|
|
||||||
|
|
||||||
##
|
|
||||||
## @brief Get the list of default color
|
|
||||||
## @return A map with keys: "default","red","green","yellow","blue","purple","cyan"
|
|
||||||
##
|
|
||||||
def get_color_set() :
|
|
||||||
global color_default
|
|
||||||
global color_red
|
|
||||||
global color_green
|
|
||||||
global color_yellow
|
|
||||||
global color_blue
|
|
||||||
global color_purple
|
|
||||||
global color_cyan
|
|
||||||
return {
|
|
||||||
"default": color_default,
|
|
||||||
"red": color_red,
|
|
||||||
"green": color_green,
|
|
||||||
"yellow": color_yellow,
|
|
||||||
"blue": color_blue,
|
|
||||||
"purple": color_purple,
|
|
||||||
"cyan": color_cyan,
|
|
||||||
}
|
|
@@ -9,7 +9,7 @@
|
|||||||
##
|
##
|
||||||
|
|
||||||
# Local import
|
# Local import
|
||||||
from . import debug
|
from realog import debug
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
@@ -26,8 +26,36 @@ 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:
|
||||||
|
# all is good ...
|
||||||
|
pass
|
||||||
|
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:
|
||||||
|
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:
|
||||||
|
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:
|
||||||
|
island_root_path = os.path.join(os.getcwd(), "..", "..", "..", "..", "..", "..")
|
||||||
|
else:
|
||||||
|
#debug.error("the root path of " + get_system_base_name() + " must not be upper that 6 parent path")
|
||||||
|
pass
|
||||||
island_path = os.path.join(island_root_path, "." + get_system_base_name())
|
island_path = os.path.join(island_root_path, "." + get_system_base_name())
|
||||||
island_path_config = os.path.join(island_path, "config.txt")
|
island_path_config = os.path.join(island_path, "config.txt")
|
||||||
island_path_manifest = os.path.join(island_path, "manifest")
|
island_path_manifest = os.path.join(island_path, "manifest")
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
# Local import
|
# Local import
|
||||||
from . import debug
|
from realog import debug
|
||||||
|
|
||||||
# print os.name # ==> 'posix'
|
# print os.name # ==> 'posix'
|
||||||
if platform.system() == "Linux":
|
if platform.system() == "Linux":
|
||||||
|
@@ -12,34 +12,13 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import copy
|
import copy
|
||||||
# Local import
|
# Local import
|
||||||
from . import debug
|
from realog import debug
|
||||||
from . import tools
|
from . import tools
|
||||||
from . import env
|
from . import env
|
||||||
from . import multiprocess
|
from . import multiprocess
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
|
|
||||||
def load_config():
|
|
||||||
config_property = tools.file_read_data(env.get_island_path_config())
|
|
||||||
element_config = config_property.split("\n")
|
|
||||||
if len(element_config) != 3:
|
|
||||||
debug.error("error in configuration property")
|
|
||||||
if element_config[0][:5] != "repo=":
|
|
||||||
debug.error("error in configuration property (2)")
|
|
||||||
if element_config[1][:7] != "branch=":
|
|
||||||
debug.error("error in configuration property (3)")
|
|
||||||
if element_config[2][:5] != "file=":
|
|
||||||
debug.error("error in configuration property (4)")
|
|
||||||
configuration = {
|
|
||||||
"repo":element_config[0][5:],
|
|
||||||
"branch":element_config[1][7:],
|
|
||||||
"file":element_config[2][5:]
|
|
||||||
}
|
|
||||||
debug.info("configuration property: " + str(configuration))
|
|
||||||
return configuration
|
|
||||||
|
|
||||||
|
|
||||||
class RepoConfig():
|
class RepoConfig():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.name = ""
|
self.name = ""
|
||||||
@@ -99,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 != "":
|
||||||
@@ -252,9 +236,9 @@ class Manifest():
|
|||||||
out = []
|
out = []
|
||||||
if default == None:
|
if default == None:
|
||||||
if self.default != None:
|
if self.default != None:
|
||||||
tmp_default = copy.deepcopy(self.default)
|
default = copy.deepcopy(self.default)
|
||||||
else:
|
else:
|
||||||
tmp_default = copy.deepcopy(self.default_base)
|
default = copy.deepcopy(self.default_base)
|
||||||
# debug.error(" self.default=" + str(self.default))
|
# debug.error(" self.default=" + str(self.default))
|
||||||
# add all local project
|
# add all local project
|
||||||
for elem in self.projects:
|
for elem in self.projects:
|
||||||
@@ -302,7 +286,7 @@ class Manifest():
|
|||||||
upper_remotes_forward.append(remote)
|
upper_remotes_forward.append(remote)
|
||||||
# add all include project
|
# add all include project
|
||||||
for elem in self.includes:
|
for elem in self.includes:
|
||||||
list_project = elem["manifest"].get_all_configs(tmp_default, upper_remotes_forward)
|
list_project = elem["manifest"].get_all_configs(default, upper_remotes_forward)
|
||||||
for elem_proj in list_project:
|
for elem_proj in list_project:
|
||||||
out.append(elem_proj)
|
out.append(elem_proj)
|
||||||
return out
|
return out
|
||||||
|
@@ -16,7 +16,7 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import shlex
|
import shlex
|
||||||
# Local import
|
# Local import
|
||||||
from . import debug
|
from realog import debug
|
||||||
from . import tools
|
from . import tools
|
||||||
from . import env
|
from . import env
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ def run_command_direct(cmd_line, cwd=None):
|
|||||||
if sys.version_info >= (3, 0):
|
if sys.version_info >= (3, 0):
|
||||||
output = output.decode("utf-8")
|
output = output.decode("utf-8")
|
||||||
err = err.decode("utf-8")
|
err = err.decode("utf-8")
|
||||||
# Check error :
|
# Check errors:
|
||||||
if p.returncode == 0:
|
if p.returncode == 0:
|
||||||
if output == None:
|
if output == None:
|
||||||
return err[:-1];
|
return err[:-1];
|
||||||
|
@@ -14,7 +14,7 @@ import errno
|
|||||||
import fnmatch
|
import fnmatch
|
||||||
import stat
|
import stat
|
||||||
# Local import
|
# Local import
|
||||||
from . import debug
|
from realog import debug
|
||||||
from . import env
|
from . import env
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
10
setup.py
10
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.3.2',
|
version='0.6.0',
|
||||||
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',
|
||||||
@@ -39,11 +39,17 @@ setup(name='island',
|
|||||||
#],
|
#],
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'lxml',
|
'lxml',
|
||||||
|
'realog',
|
||||||
|
'death',
|
||||||
],
|
],
|
||||||
include_package_data = True,
|
include_package_data = True,
|
||||||
zip_safe=False)
|
zip_safe=False)
|
||||||
|
|
||||||
#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