Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
6fda840ae5 | |||
7a46b3c0f9 | |||
bc556ee89b | |||
7f88a7cc34 | |||
9f11499b34 | |||
6da4400509 | |||
0f47c841fd | |||
bc82c533f1 | |||
f8de06c4d9 | |||
1d70339f72 | |||
e3a8d32557 | |||
e1a8280e01 | |||
a605da450f | |||
94f79962c4 | |||
9086c073a1 | |||
d362d47889 |
@@ -54,35 +54,33 @@ def init():
|
||||
|
||||
is_init = True
|
||||
|
||||
|
||||
myArgs = arguments.islandArg()
|
||||
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()
|
||||
# initialize the system ...
|
||||
init()
|
||||
|
||||
|
||||
"""
|
||||
display the help of this makefile
|
||||
"""
|
||||
debug.verbose("List of actions: " + str(actions.get_list_of_action()))
|
||||
|
||||
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():
|
||||
color = debug.get_color_set()
|
||||
# generic argument displayed :
|
||||
myArgs.display()
|
||||
my_args.display()
|
||||
print(" Action availlable" )
|
||||
list_actions = actions.get_list_of_action();
|
||||
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(" initialize a 'island' interface with a manifest in a git ")
|
||||
@@ -131,6 +129,10 @@ def parseGenericArg(argument, active):
|
||||
else:
|
||||
debug.disable_color()
|
||||
return True
|
||||
elif argument.get_option_name() == "no-fetch-manifest":
|
||||
if active == False:
|
||||
env.set_fetch_manifest(False)
|
||||
return True
|
||||
return False
|
||||
|
||||
"""
|
||||
@@ -186,15 +188,12 @@ if os.path.isfile(config_file) == True:
|
||||
"""
|
||||
|
||||
# parse default unique argument:
|
||||
for argument in localArgument:
|
||||
for argument in local_argument:
|
||||
parseGenericArg(argument, True)
|
||||
|
||||
# initialize the system ...
|
||||
init()
|
||||
|
||||
# remove all generic arguments:
|
||||
new_argument_list = []
|
||||
for argument in localArgument:
|
||||
for argument in local_argument:
|
||||
if parseGenericArg(argument, False) == True:
|
||||
continue
|
||||
new_argument_list.append(argument)
|
||||
@@ -220,12 +219,12 @@ if action_to_do not in list_actions:
|
||||
|
||||
# todo : Remove this
|
||||
if action_to_do != "init" \
|
||||
and os.path.exists("." + env.get_system_base_name()) == False:
|
||||
debug.error("Can not execute a island cmd if we have not initialize a config: '" + str("." + env.get_system_base_name()) + "'")
|
||||
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()) + "' in upper 6 parent path")
|
||||
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;
|
||||
#multiprocess.un_init()
|
||||
|
@@ -13,6 +13,7 @@ from . import debug
|
||||
import os
|
||||
import sys
|
||||
from . import env
|
||||
from . import arguments
|
||||
|
||||
list_actions = []
|
||||
|
||||
@@ -61,25 +62,58 @@ def get_desc(action_name):
|
||||
sys.path.append(os.path.dirname(elem["path"]))
|
||||
the_action = __import__(__base_action_name + action_name)
|
||||
if "get_desc" not in dir(the_action):
|
||||
debug.error("execute is not implmented for this action ... '" + str(action_name) + "'")
|
||||
return None
|
||||
return ""
|
||||
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;
|
||||
# TODO: Move here the check if action is availlable
|
||||
|
||||
for elem in list_actions:
|
||||
if elem["name"] == action_name:
|
||||
debug.info("action: " + str(elem));
|
||||
# finish the parsing
|
||||
sys.path.append(os.path.dirname(elem["path"]))
|
||||
the_action = __import__(__base_action_name + action_name)
|
||||
if "execute" not in dir(the_action):
|
||||
debug.error("execute is not implmented for this action ... '" + str(action_name) + "'")
|
||||
if elem["name"] != action_name:
|
||||
continue
|
||||
debug.info("action: " + str(elem));
|
||||
# finish the parsing
|
||||
sys.path.append(os.path.dirname(elem["path"]))
|
||||
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
|
||||
return the_action.execute(argument_list)
|
||||
# now we can execute:
|
||||
if "execute" not in dir(the_action):
|
||||
debug.error("execute is not implmented for this action ... '" + str(action_name) + "'")
|
||||
return False
|
||||
debug.info("execute: " + action_name)
|
||||
for elem in my_under_args:
|
||||
debug.info(" " + str(elem.get_option_name()) + "='" + str(elem.get_arg()) + "'")
|
||||
return the_action.execute(my_under_args)
|
||||
debug.error("Can not do the action...")
|
||||
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 "---"
|
||||
|
@@ -11,6 +11,7 @@
|
||||
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
|
||||
@@ -19,21 +20,18 @@ 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")
|
||||
my_args.add_arg("branch", optionnal=False, desc="Branch to checkout")
|
||||
|
||||
def execute(arguments):
|
||||
debug.info("execute:")
|
||||
for elem in arguments:
|
||||
debug.info(" '" + str(elem.get_arg()) + "'")
|
||||
if len(arguments) != 1:
|
||||
debug.error("checkout: missing argument to select the new branch ...")
|
||||
argument_remote_name = ""
|
||||
branch_to_checkout = ""
|
||||
for elem in arguments:
|
||||
if elem.get_option_name() == "":
|
||||
if branch_to_checkout != "":
|
||||
debug.error("checkout branch already set : '" + branch_to_checkout + "' !!! '" + elem.get_arg() + "'")
|
||||
if elem.get_option_name() == "remote":
|
||||
debug.info("find remote name: '" + elem.get_arg() + "'")
|
||||
argument_remote_name = elem.get_arg()
|
||||
elif elem.get_option_name() == "branch":
|
||||
branch_to_checkout = elem.get_arg()
|
||||
else:
|
||||
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:
|
||||
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:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
@@ -89,11 +91,9 @@ def execute(arguments):
|
||||
list_branch2 = []
|
||||
select_branch = ""
|
||||
for elem_branch in list_branch:
|
||||
list_branch2.append(elem_branch[2:])
|
||||
if elem_branch[:2] == "* ":
|
||||
list_branch2.append([elem_branch[2:], True])
|
||||
select_branch = elem_branch[2:]
|
||||
else:
|
||||
list_branch2.append([elem_branch[2:], False])
|
||||
|
||||
|
||||
# check if we are on the good branch:
|
||||
@@ -102,23 +102,36 @@ def execute(arguments):
|
||||
continue
|
||||
|
||||
# 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:
|
||||
cmd = "git checkout " + branch_to_checkout
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||
if ret[1] != "" \
|
||||
if ret[0] != 0 \
|
||||
and ret[1] != "" \
|
||||
and ret != False:
|
||||
debug.info("'" + ret + "'")
|
||||
debug.error("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> Can not checkout to the corest branch")
|
||||
debug.info("'" + str(ret) + "'")
|
||||
debug.error("checkout " + str(id_element) + "/" + str(len(all_project)) + " : " + str(elem.name) + " ==> Can not checkout to the correct branch")
|
||||
continue
|
||||
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 ....
|
||||
|
||||
continue
|
||||
|
||||
|
||||
# TODO: Check if the remote branch exist ...
|
||||
|
||||
# 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:
|
||||
cmd = "git checkout --quiet " + elem.select_remote["name"] + "/" + branch_to_checkout + " -b " + branch_to_checkout
|
||||
|
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)
|
||||
|
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 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 "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)
|
||||
|
@@ -11,16 +11,19 @@
|
||||
from island import debug
|
||||
from island import tools
|
||||
from island import env
|
||||
from island import config
|
||||
from island import multiprocess
|
||||
import os
|
||||
|
||||
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):
|
||||
debug.info("execute:")
|
||||
for elem in arguments:
|
||||
debug.info(" '" + str(elem.get_arg()) + "'")
|
||||
if len(arguments) == 0:
|
||||
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
|
||||
|
||||
# create the file configuration:
|
||||
data = "repo=" + address_manifest + "\nbranch=" + branch + "\nfile=" + manifest_name
|
||||
tools.file_write_data(env.get_island_path_config(), data)
|
||||
conf = config.Config()
|
||||
conf.set_manifest(address_manifest)
|
||||
conf.set_branch(branch)
|
||||
conf.set_manifest_name(manifest_name)
|
||||
conf.store()
|
||||
|
||||
#clone the manifest repository
|
||||
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 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)
|
||||
|
@@ -12,6 +12,7 @@ from island import debug
|
||||
from island import tools
|
||||
from island import env
|
||||
from island import multiprocess
|
||||
from island import config
|
||||
from island import manifest
|
||||
import os
|
||||
|
||||
@@ -20,15 +21,18 @@ 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):
|
||||
debug.info("execute:")
|
||||
argument_remote_name = ""
|
||||
for elem in arguments:
|
||||
debug.info(" '" + str(elem.get_arg()) + "'")
|
||||
if len(arguments) != 0:
|
||||
debug.error("status have not parameter")
|
||||
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 \
|
||||
@@ -36,9 +40,9 @@ def execute(arguments):
|
||||
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 = 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:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
@@ -61,28 +65,42 @@ def execute(arguments):
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret_diff = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||
# get local branch
|
||||
cmd = "git branch"
|
||||
cmd = "git branch -a"
|
||||
debug.verbose("execute : " + cmd)
|
||||
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
|
||||
if ret_diff[0] == 0:
|
||||
is_modify = False
|
||||
|
||||
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:])
|
||||
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 = " "
|
||||
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]) + "'")
|
||||
|
||||
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] + ")")
|
||||
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:
|
||||
cmd = "git status --short"
|
||||
debug.verbose("execute : " + cmd)
|
||||
|
@@ -11,6 +11,7 @@
|
||||
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
|
||||
@@ -22,11 +23,7 @@ def help():
|
||||
|
||||
|
||||
|
||||
|
||||
def execute(arguments):
|
||||
debug.info("execute:")
|
||||
for elem in arguments:
|
||||
debug.info(" '" + str(elem.get_arg()) + "'")
|
||||
if len(arguments) != 0:
|
||||
debug.error("Sync have not parameter")
|
||||
|
||||
@@ -37,14 +34,14 @@ def execute(arguments):
|
||||
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()) + "'")
|
||||
# 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["file"])
|
||||
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) + "'")
|
||||
|
||||
@@ -63,7 +60,12 @@ def execute(arguments):
|
||||
#clone the manifest repository
|
||||
address_manifest = ""
|
||||
|
||||
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@":
|
||||
cmd += ":"
|
||||
else:
|
||||
cmd += "/"
|
||||
cmd += elem.name + " --branch " + elem.branch + " --origin " + elem.select_remote["name"] + " " + git_repo_path
|
||||
debug.info("clone the repo")
|
||||
ret = multiprocess.run_command_direct(cmd)
|
||||
if ret != "" \
|
||||
@@ -75,7 +77,12 @@ def execute(arguments):
|
||||
# add global mirror list
|
||||
for mirror in elem.select_remote["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)
|
||||
if ret != "" \
|
||||
and ret != False:
|
||||
@@ -118,6 +125,7 @@ def execute(arguments):
|
||||
# simply update the repository ...
|
||||
debug.verbose("Fetching project: ")
|
||||
# fetch the repository
|
||||
|
||||
cmd = "git fetch " + elem.select_remote["name"]
|
||||
debug.verbose("execute : " + cmd)
|
||||
multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||
@@ -153,12 +161,26 @@ def execute(arguments):
|
||||
if is_modify == True:
|
||||
debug.warning("[" + elem.name + "] Not update ==> the repository is modified")
|
||||
continue
|
||||
|
||||
""" # TODO: this does not work ...
|
||||
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 + "'")
|
||||
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:
|
||||
if elem.select_remote["sync"] == True \
|
||||
and os.path.exists(os.path.join(git_repo_path, ".gitmodules")) == True:
|
||||
|
@@ -83,6 +83,8 @@ class ArgDefine:
|
||||
self.have_param = False
|
||||
self.description = desc;
|
||||
|
||||
def is_parsable(self):
|
||||
return True
|
||||
##
|
||||
## @brief Get the small name of the option ex: '-v'
|
||||
## @param[in] self Class handle
|
||||
@@ -165,6 +167,88 @@ class ArgDefine:
|
||||
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
|
||||
##
|
||||
@@ -181,6 +265,9 @@ class ArgSection:
|
||||
self.section = sectionName;
|
||||
self.description = desc;
|
||||
|
||||
def is_parsable(self):
|
||||
return False
|
||||
|
||||
##
|
||||
## @brief Compatibility with @ref ArgDefine class
|
||||
## @param[in] self Class handle
|
||||
@@ -215,6 +302,9 @@ class ArgSection:
|
||||
print(" [" + color['blue'] + self.section + color['default'] + "] : " + self.description)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##
|
||||
## @brief Class to define the agmument list availlable for a program
|
||||
##
|
||||
@@ -225,6 +315,8 @@ class islandArg:
|
||||
##
|
||||
def __init__(self):
|
||||
self.list_properties = []
|
||||
self._list_element_stop = []
|
||||
self._last_element_parsed = 0
|
||||
|
||||
##
|
||||
## @brief Add a new argument possibilities...
|
||||
@@ -238,6 +330,9 @@ class islandArg:
|
||||
def add(self, smallOption="", bigOption="", list=[], desc="", haveParam=False):
|
||||
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
|
||||
## @param[in] self Class handle
|
||||
@@ -250,17 +345,24 @@ class islandArg:
|
||||
##
|
||||
## @brief Parse the argument set in the command line
|
||||
## @param[in] self Class handle
|
||||
## @param[in] start_position_parsing position to start the parsing in the arguments
|
||||
##
|
||||
def parse(self):
|
||||
listArgument = [] # composed of list element
|
||||
NotparseNextElement=False
|
||||
for iii in range(1, len(sys.argv)):
|
||||
def parse(self, start_position_parsing=1):
|
||||
list_argument = [] # composed of list element
|
||||
not_parse_next_element=False
|
||||
for iii in range(start_position_parsing, len(sys.argv)):
|
||||
self._last_element_parsed = iii
|
||||
# special case of parameter in some elements
|
||||
if NotparseNextElement==True:
|
||||
NotparseNextElement = False
|
||||
if not_parse_next_element == True:
|
||||
not_parse_next_element = False
|
||||
continue
|
||||
debug.verbose("parse [" + str(iii) + "]=" + 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("=")
|
||||
debug.verbose(str(optionList))
|
||||
if type(optionList) == type(str()):
|
||||
@@ -269,10 +371,12 @@ class islandArg:
|
||||
option = optionList[0]
|
||||
optionParam = argument[len(option)+1:]
|
||||
debug.verbose(option)
|
||||
argumentFound=False;
|
||||
if option[:2]=="--":
|
||||
argument_found=False;
|
||||
if option[:2] == "--":
|
||||
# big argument
|
||||
for prop in self.list_properties:
|
||||
if prop.is_parsable()==False:
|
||||
continue
|
||||
if prop.get_option_big()=="":
|
||||
continue
|
||||
if prop.get_option_big() == option[2:]:
|
||||
@@ -291,7 +395,7 @@ class islandArg:
|
||||
#Get the next parameters
|
||||
if len(sys.argv) > iii+1:
|
||||
optionParam = sys.argv[iii+1]
|
||||
NotparseNextElement=True
|
||||
not_parse_next_element=True
|
||||
else :
|
||||
# missing arguments
|
||||
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 + "'")
|
||||
prop.display()
|
||||
exit(-1)
|
||||
listArgument.append(ArgElement(prop.get_option_big(),optionParam))
|
||||
argumentFound = True
|
||||
list_argument.append(ArgElement(prop.get_option_big(),optionParam))
|
||||
argument_found = 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
|
||||
list_argument.append(ArgElement(prop.get_option_big()))
|
||||
argument_found = True
|
||||
break;
|
||||
if False==argumentFound:
|
||||
if argument_found == False:
|
||||
debug.error("UNKNOW argument : '" + argument + "'")
|
||||
elif option[:1]=="-":
|
||||
# small argument
|
||||
for prop in self.list_properties:
|
||||
if prop.is_parsable()==False:
|
||||
continue
|
||||
if prop.get_option_small()=="":
|
||||
continue
|
||||
if prop.get_option_small() == option[1:1+len(prop.get_option_small())]:
|
||||
@@ -333,7 +439,7 @@ class islandArg:
|
||||
#Get the next parameters
|
||||
if len(sys.argv) > iii+1:
|
||||
optionParam = sys.argv[iii+1]
|
||||
NotparseNextElement=True
|
||||
not_parse_next_element=True
|
||||
else :
|
||||
# missing arguments
|
||||
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 + "'")
|
||||
prop.display()
|
||||
exit(-1)
|
||||
listArgument.append(ArgElement(prop.get_option_big(),optionParam))
|
||||
argumentFound = True
|
||||
list_argument.append(ArgElement(prop.get_option_big(),optionParam))
|
||||
argument_found = 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
|
||||
list_argument.append(ArgElement(prop.get_option_big()))
|
||||
argument_found = True
|
||||
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 ...
|
||||
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()
|
||||
#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
|
||||
## @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:")
|
||||
listOfPropertiesArg = "";
|
||||
for element in self.list_properties :
|
||||
listOfPropertiesArg += element.get_porperties()
|
||||
print(" " + sys.argv[0] + listOfPropertiesArg + " ...")
|
||||
print(" " + sys.argv[0] + " " + action_name + " " + 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 . 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
|
||||
|
@@ -26,8 +26,36 @@ def get_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())
|
||||
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_config = os.path.join(island_path, "config.txt")
|
||||
island_path_manifest = os.path.join(island_path, "manifest")
|
||||
|
@@ -19,27 +19,6 @@ from . import multiprocess
|
||||
|
||||
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():
|
||||
def __init__(self):
|
||||
self.name = ""
|
||||
@@ -99,7 +78,12 @@ class Manifest():
|
||||
and ( fetch[0] == "/" \
|
||||
or fetch[0] == "\\"):
|
||||
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("tmp fetch=" + fetch)
|
||||
if fetch != "":
|
||||
@@ -252,9 +236,9 @@ class Manifest():
|
||||
out = []
|
||||
if default == None:
|
||||
if self.default != None:
|
||||
tmp_default = copy.deepcopy(self.default)
|
||||
default = copy.deepcopy(self.default)
|
||||
else:
|
||||
tmp_default = copy.deepcopy(self.default_base)
|
||||
default = copy.deepcopy(self.default_base)
|
||||
# debug.error(" self.default=" + str(self.default))
|
||||
# add all local project
|
||||
for elem in self.projects:
|
||||
@@ -302,7 +286,7 @@ class Manifest():
|
||||
upper_remotes_forward.append(remote)
|
||||
# add all include project
|
||||
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:
|
||||
out.append(elem_proj)
|
||||
return out
|
||||
|
8
setup.py
8
setup.py
@@ -16,7 +16,7 @@ def readme():
|
||||
|
||||
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
setup(name='island',
|
||||
version='0.3.2',
|
||||
version='0.5.0',
|
||||
description='island generic source manager (like repo in simple mode)',
|
||||
long_description=readme(),
|
||||
url='http://github.com/HeeroYui/island',
|
||||
@@ -45,5 +45,9 @@ setup(name='island',
|
||||
|
||||
#To developp: sudo ./setup.py install
|
||||
# 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