Compare commits

..

1 Commits

Author SHA1 Message Date
5097b0b041 [DEV] some modifs 2021-06-16 20:44:13 +02:00
42 changed files with 1396 additions and 1512 deletions

View File

@ -5,11 +5,16 @@
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-exml"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes> <attributes>
<attribute name="module" value="true"/> <attribute name="module" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/scenarium-logger"> <classpathentry combineaccessrules="false" exported="true" kind="src" path="/scenarium-logger">
<attributes> <attributes>
<attribute name="module" value="true"/> <attribute name="module" value="true"/>
@ -20,25 +25,5 @@
<attribute name="module" value="true"/> <attribute name="module" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry combineaccessrules="false" kind="src" path="/atriasoft-etk">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/org.eclipse.jgit-5.12.0.202106070339-r.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="out/eclipse/classes"/> <classpathentry kind="output" path="out/eclipse/classes"/>
</classpath> </classpath>

View File

@ -4,13 +4,10 @@
open module org.atriasoft.island { open module org.atriasoft.island {
exports org.atriasoft.island; exports org.atriasoft.island;
exports org.atriasoft.island.model; //exports org.atriasoft.island.model;
//exports org.atriasoft.island.actions; //exports org.atriasoft.island.actions;
requires transitive io.scenarium.logger; requires transitive io.scenarium.logger;
requires java.base; requires java.base;
requires org.atriasoft.death; requires org.atriasoft.death;
requires org.atriasoft.exml;
requires org.atriasoft.etk;
requires org.eclipse.jgit;
} }

View File

@ -1,12 +1,9 @@
package org.atriasoft.island; package org.atriasoft.island;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.atriasoft.death.ArgElement;
import org.atriasoft.death.Arguments;
import org.atriasoft.island.internal.Log; import org.atriasoft.island.internal.Log;
import org.atriasoft.island.model.ActionException; import org.atriasoft.island.model.ActionException;
import org.atriasoft.island.model.ActionInterface; import org.atriasoft.island.model.ActionInterface;
@ -20,7 +17,7 @@ public class Actions {
* Get the wall list of action availlable * Get the wall list of action availlable
* @return The list of action name * @return The list of action name
*/ */
public static Set<String> getListOfAction() { public Set<String> getListOfAction() {
return actions.keySet(); return actions.keySet();
} }
@ -49,38 +46,27 @@ public class Actions {
* Get the global help value of a module * Get the global help value of a module
* @param action_name (string) Name of the action * @param action_name (string) Name of the action
* @return The first line of description * @return The first line of description
* @throws ActionException
*/ */
private String getFullActionHelp(String action_name) throws ActionException { private String getFullActionHelp(String action_name) {
Class<ActionInterface> actionClass = actions.get(action_name); Class<ActionInterface> actionClass = actions.get(action_name);
if (actionClass == null) { if (actionClass == null) {
throw new ActionException("Action does not registered"); return "Action does not exist";
} }
ActionInterface action; ActionInterface action = actionClass.getDeclaredConstructor().newInstance();
try { if (action == null) {
action = actionClass.getDeclaredConstructor().newInstance(); return "Action creation error";
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new ActionException("Uneable to intanciate Action");
} }
return action.help(); return action.help();
} }
private String getActionHelpExample(String action_name) throws ActionException { private String getActionHelpExample(String action_name) {
Class<ActionInterface> actionClass = actions.get(action_name); Class<ActionInterface> actionClass = actions.get(action_name);
if (actionClass == null) { if (actionClass == null) {
throw new ActionException("Action does not registered"); return null;
} }
ActionInterface action; ActionInterface action = actionClass.getDeclaredConstructor().newInstance();
try { if (action == null) {
action = actionClass.getDeclaredConstructor().newInstance(); return null;
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new ActionException("Uneable to intanciate Action");
} }
return action.helpExample(); return action.helpExample();
} }
@ -89,13 +75,12 @@ public class Actions {
* Get the global help value of a module * Get the global help value of a module
* @param action_name (string) Name of the action * @param action_name (string) Name of the action
* @return The first line of description * @return The first line of description
* @throws ActionException
*/ */
public String getActionHelp(String action_name) throws ActionException { public String getActionHelp(String action_name) {
return getFullActionHelp(action_name).split("\n")[0]; return getFullActionHelp(action_name).split("\n")[0];
} }
public void usage(String action_name, Arguments arguments) throws ActionException { public void usage(String action_name, List<String> arguments) {
String help = getFullActionHelp(action_name); String help = getFullActionHelp(action_name);
Log.print("Description:"); Log.print("Description:");
Log.print("\t" + help); Log.print("\t" + help);
@ -110,18 +95,13 @@ public class Actions {
System.exit(0); System.exit(0);
} }
public void execute(String action_name, List<String> arguments) throws ActionException { public void execute(String action_name, List<String> arguments) {
Class<ActionInterface> actionClass = actions.get(action_name); Class<ActionInterface> actionClass = actions.get(action_name);
if (actionClass == null) { if (actionClass == null) {
throw new ActionException("Action does not registered"); throw new ActionException("Action does not registered");
} }
ActionInterface action = null; ActionInterface action = actionClass.getDeclaredConstructor().newInstance();
try { if (action == null) {
action = actionClass.getDeclaredConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
| NoSuchMethodException | SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new ActionException("Uneable to intanciate Action"); throw new ActionException("Uneable to intanciate Action");
} }
Log.info("action: " + action_name); Log.info("action: " + action_name);
@ -129,18 +109,18 @@ public class Actions {
my_under_args_parser.add("h", "help", null, "Help of this action"); my_under_args_parser.add("h", "help", null, "Help of this action");
action.addSpecificArguments(my_under_args_parser, action_name); action.addSpecificArguments(my_under_args_parser, action_name);
boolean have_unknow_argument = action.haveUnknowArgument(); boolean have_unknow_argument = action.haveUnknowArgument();
List<ArgElement> my_under_args = my_under_args_parser.parse(arguments, have_unknow_argument); my_under_args = my_under_args_parser.parse(arguments, have_unknow_argument);
// search help if needed ==> permit to not duplicating code // search help if needed ==> permit to not duplicating code
for (ArgElement elem : my_under_args) { for (elem : my_under_args) {
if (elem.getOptionName() == "help") { if (elem.get_option_name() == "help") {
usage(action_name, my_under_args_parser); usage(my_under_args_parser, action_name);
System.exit(0); System.exit(0);
} }
} }
// now we can execute: // now we can execute:
Log.info("execute: " + action_name); Log.info("execute: " + action_name);
for (ArgElement elem : my_under_args) { for (elem : my_under_args) {
Log.debug(" " + elem.getOptionName() + "='" + elem.getArg() + "'"); Log.debug(" " + elem.get_option_name() + "='" + elem.get_arg() + "'");
} }
action.execute(my_under_args); action.execute(my_under_args);
} }

View File

@ -1,13 +0,0 @@
package org.atriasoft.island;
import org.atriasoft.island.model.ConfigManifest;
public class Config {
private static ConfigManifest config;
public static ConfigManifest getUniqueConfig() {
if (config == null) {
config = ConfigManifest.load();
}
return config;
}
}

View File

@ -91,6 +91,7 @@ public class Env {
private static Path island_root_path = null; private static Path island_root_path = null;
private static Path island_path_user_config = null; private static Path island_path_user_config = null;
private static Path island_path = null; private static Path island_path = null;
private static Path island_path_config_old = null;
private static Path island_path_config = null; private static Path island_path_config = null;
private static Path island_path_manifest = null; private static Path island_path_manifest = null;
@ -109,13 +110,14 @@ public class Env {
island_root_path = tmpPath; island_root_path = tmpPath;
island_path_user_config = island_root_path.resolve(get_system_config_name()); island_path_user_config = island_root_path.resolve(get_system_config_name());
island_path = island_root_path.resolve("." + get_system_base_name()); island_path = island_root_path.resolve("." + get_system_base_name());
island_path_config = island_path.resolve("config.xml"); island_path_config_old = island_path.resolve("config.txt");
island_path_config = island_path.resolve("config.json");
island_path_manifest = island_path.resolve("manifest"); island_path_manifest = island_path.resolve("manifest");
} }
/** //#
* To use later to know where the ".island" parent path is ... //# @brief to use later to know where the ".island" parent path is ...
* @return the parent path of the ".island" //# @return the parent path of the ".island"
*/ //#
public static Path get_island_root_path() { public static Path get_island_root_path() {
return island_root_path; return island_root_path;
} }
@ -125,7 +127,9 @@ public class Env {
public static Path get_island_path_config() { public static Path get_island_path_config() {
return island_path_config; return island_path_config;
} }
public static Path get_island_path_config_old() {
return island_path_config_old;
}
public static Path get_island_path_manifest() { public static Path get_island_path_manifest() {
return island_path_manifest; return island_path_manifest;
} }
@ -137,6 +141,7 @@ public class Env {
Log.error("island_root_path = " + island_root_path.toAbsolutePath()); Log.error("island_root_path = " + island_root_path.toAbsolutePath());
Log.error("island_path_user_config = " + island_path_user_config.toAbsolutePath()); Log.error("island_path_user_config = " + island_path_user_config.toAbsolutePath());
Log.error("island_path = " + island_path.toAbsolutePath()); Log.error("island_path = " + island_path.toAbsolutePath());
Log.error("island_path_config_old = " + island_path_config_old.toAbsolutePath());
Log.error("island_path_config = " + island_path_config.toAbsolutePath()); Log.error("island_path_config = " + island_path_config.toAbsolutePath());
Log.error("island_path_manifest = " + island_path_manifest.toAbsolutePath()); Log.error("island_path_manifest = " + island_path_manifest.toAbsolutePath());

View File

@ -1,39 +1,36 @@
package org.atriasoft.island; package org.atriasoft.island;
import java.util.Arrays;
import org.atriasoft.death.ArgChoice;
import org.atriasoft.death.Arguments; import org.atriasoft.death.Arguments;
public class MainIsland { public class MainIsland {
private static Arguments my_args = new Arguments();
//Log.verbose("List of actions: " + str(actions.get_list_of_action())) //debug.verbose("List of actions: " + str(actions.get_list_of_action()))
static { static {
Arguments my_args = new Arguments();
my_args.addSection("option", "Can be set one time in all case"); my_args.addSection("option", "Can be set one time in all case");
my_args.add("h", "help", null, "Display this help"); my_args.add("h", "help", null, "Display this help");
my_args.add("v", "verbose", Arrays.asList( my_args.add("v", "verbose", {
new ArgChoice("0","None"), ["0","None"],
new ArgChoice("1","error"), ["1","error"],
new ArgChoice("2","warning"), ["2","warning"],
new ArgChoice("3","info"), ["3","info"],
new ArgChoice("4","Log"), ["4","debug"],
new ArgChoice("5","verbose"), ["5","verbose"],
new ArgChoice("6","extreme_verbose")), "display Log level (verbose) default =2"); ["6","extreme_verbose"],
my_args.add("c", "color", null, "Display message in color"); }, desc="display debug level (verbose) default =2")
my_args.add("n", "no-fetch-manifest", null, "Disable the fetch of the manifest", false); my_args.add("c", "color", desc="Display message in color")
my_args.add("F", "filter", null, "Filter the action on a list of path or subpath: -f library", true); my_args.add("n", "no-fetch-manifest", haveParam=false, desc="Disable the fetch of the manifest")
my_args.add("f", "folder", null, "Display the folder instead of the git repository name", false); my_args.add("F", "filter", haveParam=true, desc="Filter the action on a list of path or subpath: -f library")
my_args.add("w", "wait", null, "Wait between 2 acces on the server (needed when the server is really slow to remove ssh connection) (default=" + str(env.get_wait_between_sever_command()) + ")", false); my_args.add("f", "folder", haveParam=false, desc="Display the folder instead of the git repository name")
my_args.set_stop_at(new ArrayList<Actions.getListOfAction())); my_args.add("w", "wait", haveParam=true, desc="Wait between 2 acces on the server (needed when the server is really slow to remove ssh connection) (default=" + str(env.get_wait_between_sever_command()) + ")")
my_args.set_stop_at(actions.get_list_of_action())
local_argument = my_args.parse(); local_argument = my_args.parse()
// //
// @brief Display the help of this makefile. // @brief Display the help of this makefile.
// //
public void usage(): public void usage():
color = Log.get_color_set() color = debug.get_color_set()
// generic argument displayed : // generic argument displayed :
my_args.display() my_args.display()
print(" Action availlable" ) print(" Action availlable" )
@ -62,42 +59,42 @@ public void check_boolean(value):
return true return true
return false return false
// preparse the argument to get the verbose element for Log mode // preparse the argument to get the verbose element for debug mode
public void parse_generic_arg(argument, active): public void parse_generic_arg(argument, active):
Log.extreme_verbose("parse arg : " + argument.getOptionName() + " " + argument.getArg() + " active=" + str(active)) debug.extreme_verbose("parse arg : " + argument.get_option_name() + " " + argument.get_arg() + " active=" + str(active))
if argument.getOptionName() == "help": if argument.get_option_name() == "help":
if active == false: if active == false:
usage() usage()
return true return true
} else if argument.getOptionName()=="jobs": elif argument.get_option_name()=="jobs":
if active == true: if active == true:
//multiprocess.set_core_number(int(argument.getArg())) //multiprocess.set_core_number(int(argument.get_arg()))
pass pass
return true return true
} else if argument.getOptionName()=="wait": elif argument.get_option_name()=="wait":
if active == true: if active == true:
env.set_wait_between_sever_command(int(argument.getArg())) env.set_wait_between_sever_command(int(argument.get_arg()))
return true return true
} else if argument.getOptionName() == "verbose": elif argument.get_option_name() == "verbose":
if active == true: if active == true:
Log.set_level(int(argument.getArg())) debug.set_level(int(argument.get_arg()))
return true return true
} else if argument.getOptionName() == "folder": elif argument.get_option_name() == "folder":
if active == true: if active == true:
env.set_display_folder_instead_of_git_name(true) env.set_display_folder_instead_of_git_name(true)
return true return true
} else if argument.getOptionName() == "color": elif argument.get_option_name() == "color":
if active == true: if active == true:
if check_boolean(argument.getArg()) == true: if check_boolean(argument.get_arg()) == true:
Log.enable_color() debug.enable_color()
else: else:
Log.disable_color() debug.disable_color()
return true return true
} else if argument.getOptionName() == "filter": elif argument.get_option_name() == "filter":
if active == true: if active == true:
env.set_filter_command(str(argument.getArg())) env.set_filter_command(str(argument.get_arg()))
return true return true
} else if argument.getOptionName() == "no-fetch-manifest": elif argument.get_option_name() == "no-fetch-manifest":
if active == false: if active == false:
env.set_fetch_manifest(false) env.set_fetch_manifest(false)
return true return true
@ -107,38 +104,38 @@ public void parse_generic_arg(argument, active):
config_file = env.get_island_path_user_config() config_file = env.get_island_path_user_config()
if os.path.isfile(config_file) == true: if os.path.isfile(config_file) == true:
sys.path.append(os.path.dirname(config_file)) sys.path.append(os.path.dirname(config_file))
Log.debug("Find basic configuration file: '" + config_file + "'") debug.debug("Find basic configuration file: '" + config_file + "'")
// the file exist, we can open it and get the initial configuration: // the file exist, we can open it and get the initial configuration:
configuration_file = __import__(env.get_system_config_name()[:-3]) configuration_file = __import__(env.get_system_config_name()[:-3])
if "get_exclude_path" in dir(configuration_file): if "get_exclude_path" in dir(configuration_file):
data = configuration_file.get_exclude_path() data = configuration_file.get_exclude_path()
Log.debug(" get default config 'get_exclude_path' val='" + str(data) + "'") debug.debug(" get default config 'get_exclude_path' val='" + str(data) + "'")
env.set_exclude_search_path(data) env.set_exclude_search_path(data)
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()
Log.debug(" get default config 'get_default_color' val='" + str(data) + "'") debug.debug(" get default config 'get_default_color' val='" + str(data) + "'")
parse_generic_arg(arg_element.ArgElement("color", str(data)), true) parse_generic_arg(arg_element.ArgElement("color", str(data)), true)
if "get_default_Log_level" in dir(configuration_file): if "get_default_debug_level" in dir(configuration_file):
data = configuration_file.get_default_Log_level() data = configuration_file.get_default_debug_level()
Log.debug(" get default config 'get_default_debug_level' val='" + str(data) + "'") debug.debug(" get default config 'get_default_debug_level' val='" + str(data) + "'")
parse_generic_arg(arg_element.ArgElement("verbose", str(data)), true) parse_generic_arg(arg_element.ArgElement("verbose", str(data)), true)
if "get_default_folder" in dir(configuration_file): if "get_default_folder" in dir(configuration_file):
data = configuration_file.get_default_folder() data = configuration_file.get_default_folder()
Log.debug(" get default config 'get_default_folder' val='" + str(data) + "'") debug.debug(" get default config 'get_default_folder' val='" + str(data) + "'")
parse_generic_arg(arg_element.ArgElement("folder", str(data)), true) parse_generic_arg(arg_element.ArgElement("folder", str(data)), true)
if "get_default_wait" in dir(configuration_file): if "get_default_wait" in dir(configuration_file):
data = configuration_file.get_default_wait() data = configuration_file.get_default_wait()
Log.debug(" get default config 'get_default_wait' val='" + str(data) + "'") debug.debug(" get default config 'get_default_wait' val='" + str(data) + "'")
parse_generic_arg(arg_element.ArgElement("wait", str(data)), true) parse_generic_arg(arg_element.ArgElement("wait", str(data)), true)
if "get_default_filter" in dir(configuration_file): if "get_default_filter" in dir(configuration_file):
data = configuration_file.get_default_filter() data = configuration_file.get_default_filter()
Log.debug(" get default config 'get_default_filter' val='" + str(data) + "'") debug.debug(" get default config 'get_default_filter' val='" + str(data) + "'")
parse_generic_arg(arg_element.ArgElement("filter", str(data)), true) parse_generic_arg(arg_element.ArgElement("filter", str(data)), true)
@ -156,27 +153,27 @@ for argument in local_argument:
// now the first argument is: the action: // now the first argument is: the action:
if len(new_argument_list) == 0: if len(new_argument_list) == 0:
Log.warning("--------------------------------------") debug.warning("--------------------------------------")
Log.warning("Missing the action to do ...") debug.warning("Missing the action to do ...")
Log.warning("--------------------------------------") debug.warning("--------------------------------------")
usage() usage()
// TODO : move tin in actions ... // TODO : move tin in actions ...
list_actions = actions.get_list_of_action(); list_actions = actions.get_list_of_action();
action_to_do = new_argument_list[0].getArg() action_to_do = new_argument_list[0].get_arg()
new_argument_list = new_argument_list[1:] new_argument_list = new_argument_list[1:]
if action_to_do not in list_actions: if action_to_do not in list_actions:
Log.warning("--------------------------------------") debug.warning("--------------------------------------")
Log.warning("Wrong action type : '" + str(action_to_do) + "' availlable list: " + str(list_actions) ) debug.warning("Wrong action type : '" + str(action_to_do) + "' availlable list: " + str(list_actions) )
Log.warning("--------------------------------------") debug.warning("--------------------------------------")
usage() usage()
// todo : Remove this // todo : Remove this
if action_to_do != "init" \ if action_to_do != "init" \
and os.path.exists(env.get_island_path()) == false: and os.path.exists(env.get_island_path()) == false:
Log.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") 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)

View File

@ -1,536 +0,0 @@
package org.atriasoft.island;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import org.atriasoft.exml.Exml;
import org.atriasoft.exml.model.XmlAttribute;
import org.atriasoft.exml.model.XmlElement;
import org.atriasoft.exml.model.XmlNode;
import org.atriasoft.exml.model.XmlNodeType;
import org.atriasoft.exml.parser.ParseXml;
import org.atriasoft.island.internal.Log;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.RemoteListCommand;
class RepositoryCongig {
String remote = "origin";
String revision = "master";
boolean sync = false;
}
record MirrorConfig(String name, String fetch) {
}
record RemoteConfig(String name, String fetch, List<MirrorConfig> mirror) {
}
record IncludeConfig(String name, String path, Object manifest) {
}
public class Manifest {
public static boolean isInit() {
if (!Files.exists(Env.get_island_path())){
Log.verbose("Lutin is not init: path does not exist: '" + Env.get_island_path() + "'");
return false;
}
if (!Files.exists(Env.get_island_path_config())) {
Log.verbose("Lutin is not init: config does not exist: '" + Env.get_island_path_config() + "'");
return false;
}
if (!Files.exists(Env.get_island_path_manifest())) {
Log.verbose("Lutin is not init: Manifest does not exist: '" + Env.get_island_path_manifest() + "'");
return false;
}
return true;
}
public static void checkIsInit() {
// check if .XXX exist (create it if needed)
if (!isInit()) {
Log.error("System not init: missing config: '" + Env.get_island_path() + "'. Call <island init> first");
System.exit(-1);
}
}
private String deliver_master = "master";
private String deliver_develop = "develop";
private String deliver_mode = "merge";
private Path manifestXml;
List<Object> projects = new ArrayList<>();
RepositoryCongig defaultWhat = null;
RepositoryCongig default_base = new RepositoryCongig();
List<RemoteConfig> remotes = new ArrayList<>();
List<IncludeConfig> includes = new ArrayList<>();
List<Object> links = new ArrayList<>();
public Manifest(Path manifest_xml) {
manifestXml = manifest_xml;
// load the manifest
load();
// check error in manifest (double path ...)
// TODO checkDoublePath();
}
public List<Object> getLinks() {
return this.links;
}
String removeEndSlash(String value) {
while (value.length() > 1
&& ( value.charAt(value.length()-1) == '\\'
|| value.charAt(value.length()-1) == '/')) {
value = value.substring(0, value.length()-1);
}
return value;
}
public void load() {
XmlElement rootNode = Exml.parse(this.manifestXml);
Log.debug("manifest : '" + this.manifestXml + "'");
if (!rootNode.getValue().equals("manifest")) {
Log.error(" in '" + this.manifestXml + "' have not main xml node='manifest'");
}
for (XmlNode child : rootNode.getNodes()) {
if (child.getType() == XmlNodeType.COMMENT) {
Log.verbose(" comment='" + child + "'");
continue;
}
if (child.getValue().equals("remote")) {
String name = "origin";
String fetch = "";
for (XmlAttribute attr : child.toElement().getAttributes()) {
if (attr.getName().equals("name")) {
name = attr.getValue();
} else if (attr.getName().equals("fetch")) {
fetch = attr.getValue();
// When we use manifest with relative element of the manifest git.
if (fetch.length() >= 2 && fetch.startsWith("..")) {
// we have a relative island manifest ==> use local manifest origin to get the full origin
Git git = Git.open(Env.get_island_path_manifest().toFile());
RemoteListCommand remoteList = git.remoteList();
// cmd = "git remote get-url origin"
// Log.verbose("execute : " + cmd)
// base_origin = multiprocess.run_command(cmd, cwd=)
// Log.verbose("base_origin=" + base_origin[1])
// base_origin = base_origin[1]
// while len(fetch) >= 2 \
// and fetch[:2] == "..":
// fetch = fetch[2:]
// while len(fetch) >= 1 \
// and ( fetch[0] == "/" \
// or fetch[0] == "\\"):
// fetch = fetch[1:]
// 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]
// Log.verbose("new base_origin=" + base_origin)
// Log.verbose("tmp fetch=" + fetch)
// if fetch != "":
// fetch = base_origin + "/" + fetch
// else:
// fetch = base_origin
Log.verbose("new fetch=" + fetch);
}
fetch = removeEndSlash(fetch);
} else {
Log.error("Parsing the manifest : Unknow '" + child.getName() + "' attibute : '" + attr.getName() + "', availlable:[name,fetch]")
}
}
Log.debug(" find '" + child.getName() + "' : name='" + name + "' fetch='" + fetch + "'");
// parse the sub global mirror list
List<MirrorConfig> mirror_list = new ArrayList<>();
for (XmlNode child_2 : child.toElement().getNodes()) {
if (child_2.getValue().equals("mirror")):
// find a new mirror
String mirror_name = "";
String mirror_fetch = "";
for (XmlAttribute attr_2 : child_2.toElement().getAttributes()) {
if (attr_2.getName().equals("name")) {
mirror_name = attr_2.getValue();
} else if (attr_2.getName().equals("fetch")) {
mirror_fetch = attr_2.getValue();
mirror_fetch = removeEndSlash(mirror_fetch);
} else {
Log.error("Parsing the manifest : Unknow '" + child_2.getValue() + "' attibute : '" + attr_2 + "', availlable:[name,fetch]");
}
}
Log.debug("mirror: '" + mirror_name + "' '" + mirror_fetch + "'");
if (mirror_name.isEmpty()) {
Log.critical("Missing mirrot 'name'");
}
if (mirror_fetch.isEmpty()) {
Log.critical("Missing mirror 'fetch'");
}
mirror_list.add(new MirrorConfig(mirror_name, mirror_fetch));
} else {
Log.critical("Parsing the manifest : Unknow '" + child_2.getName() + "', availlable:[mirror]");
}
this.remotes.add(new RemoteConfig(name, fetch, mirror_list));
continue;
}
if (child.getName().equals("include") {
String name = "";
for (XmlAttribute attr : child.toElement.getAttributes()) {
if (attr.getName().equals("name")) {
name = attr.getValue();
} else {
Log.error("Parsing the manifest : Unknow '" + child.getName() + "' attibute : '" + attr + "', availlable:[name]")
}
}
Log.debug(" find '" + child.getName() + "' : name='" + name + "'");
// check if the file exist ...
Path new_name_xml = this.manifest_xml.resolve(name);
if (!Files.exists(new_name_xml)) {
Log.critical("The file does not exist: " + new_name_xml)
}
this.includes.add(new IncludeConfig(name, new_name_xml, null));
continue;
}
if (child.getName().equals("default") {
String remote = "origin";
String revision = "master";
boolean sync = false;
for (XmlAttribute attr : child.toElement.getAttributes()) {
if (attr.getName().equals("remote")) {
remote = attr.getValue();
} else if (attr.getName().equals("revision")) {
revision = attr.getValue();
} else if (attr.getName().equals("sync-s")) { // synchronize submodule ... automaticaly
sync = attr.getValue();
if (sync.lower().equals("true")
|| sync.equals("1")
|| sync.lower().equals("yes")) {
sync = true;
} else if (sync.lower().equals("false")
|| sync.equals("0")
|| sync.lower().equals("no")) {
sync = false
} else {
Log.critical("Parsing the manifest : Unknow '" + child.getName() + "' attibute : '" + attr + "', value:'" + sync + "' availlable:[true,1,yes,false,0,no]");
}
} else {
Log.error("Parsing the manifest : Unknow '" + child.getName() + "' attibute : '" + attr + "', availlable:[remote,revision,sync-s]");
}
}
if (this.defaultWhat != null) {
Log.error("Parsing the manifest : Node '" + child.getName() + "' already set")
}
this.defaultWhat = new RepositoryCongig(remote, revision, sync));
Log.debug(" find '" + child.getName() + "' : remote='" + remote + "' revision='" + revision + "' sync=" + sync);
continue;
}
if child.tag == "project":
name = ""
path = ""
tag_sha1 = None
for attr in child.attrib:
if attr == "name":
name = child.attrib[attr]
} else if attr == "path":
path = child.attrib[attr]
} else if attr == "tag":
tag_sha1 = child.attrib[attr]
else:
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name,tag,sync-s]")
if name == "":
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'name' ==> specify the git to clone ...")
this.projects.append({
"name":name,
"path":path,
"tag":tag_sha1,
})
Log.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "' path='" + path + "' tag='" + str(tag_sha1) + "'");
continue
if child.tag == "option":
// not managed ==> future use
type_option = ""
value_option = ""
for attr in child.attrib:
if attr == "type":
type_option = child.attrib[attr]
} else if attr == "value":
value_option = child.attrib[attr]
else:
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[type,value]")
if type_option == "deliver_master":
this.deliver_master = value_option
} else if type_option == "deliver_develop":
this.deliver_develop = value_option
} else if type_option == "deliver_mode":
this.deliver_mode = value_option
if this.deliver_mode not in ["merge","fast_forward"]:
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: option 'deliver_mode' value availlable: [merge,fast_forward]")
else:
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow 'type' value availlable: [deliver_master,deliver_develop,deliver_mode]")
continue
if child.tag == "link":
// not managed ==> future use
source = ""
destination = ""
for attr in child.attrib:
if attr == "source":
source = child.attrib[attr]
} else if attr == "destination":
destination = child.attrib[attr]
else:
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[source,destination]")
if source == "":
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'source' ==> specify the git to clone ...")
if destination == "":
Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'destination' ==> specify the git to clone ...")
this.links.append({
"source":source,
"destination":destination,
})
Log.debug("Add link: '" + str(destination) + "' ==> '" + str(source) + "'")
continue
Log.info("(l:" + str(child.sourceline) + ") '" + str(child.tag) + "' values=" + str(child.attrib));
Log.error("(l:" + str(child.sourceline) + ") Parsing error Unknow NODE : '" + str(child.tag) + "' availlable:[remote,include,default,project,option,link]")
// now we parse all sub repo:
for elem in this.includes:
elem["manifest"] = Manifest(elem["path"])
// inside data child.text
// public void _create_path_with_elem(this, element):
// path = element["path"]
// if path == "":
// path = element["name"]
// if len(path) >= 4 \
// and path[-4:] == ".git":
// path = path[:-4]
// return path
//
// public void checkDoublePath(this, list_path = [], space=""):
// Log.debug(space + "check path : '" + this.manifest_xml + "'")
// for elem in this.projects:
// path = this._create_path_with_elem(elem)
// Log.debug(space + " check path:'" + str(path) + "'")
// if path in list_path:
// Log.error("Check Manifest error : double use of the path '" + str(path) + "'")
// list_path.append(path)
// for elem in this.includes:
// elem["manifest"]._check_double_path(list_path, space + " ")
//
// public void get_all_configs(this, default=None, upper_remotes=[]):
// out = []
// if default == None:
// if this.default != None:
// default = copy.deepcopy(this.default)
// else:
// default = copy.deepcopy(this.default_base)
// // Log.error(" this.default=" + str(this.default))
// // add all local project
// for elem in this.projects:
// Log.verbose("parse element " + str(elem))
// if Env.need_process_with_filter(elem["name"]) == false:
// Log.info("Filter repository: " + str(elem["name"]))
// continue
// conf = repo_config.RepoConfig()
// conf.name = elem["name"]
// conf.tag = elem["tag"]
// conf.path = this._create_path_with_elem(elem)
//
// // add default remote for the project (search in herited element)
// for remote in this.remotes:
// Log.verbose(" Local Remote: " + str(remote))
// if remote["name"] == default["remote"]:
// conf.remotes.append(remote)
// if len(conf.remotes) == 0:
// for remote in upper_remotes:
// Log.verbose(" upper Remote: " + str(remote))
// if remote["name"] == default["remote"]:
// conf.remotes.append(remote)
// if len(conf.remotes) == 0:
// Log.error(" No remote detected: " + str(len(conf.remotes)) + " for " + conf.name + " with default remote name : " + default["remote"] + " this remote: " + str(this.remotes))
//
// // select default remote:
// conf.select_remote = None
// Log.debug(" remotes count: " + str(len(conf.remotes)))
// for remote in conf.remotes:
// Log.debug(" remote=" + str(remote))
// Log.debug(" Ckeck remote : " + remote["name"] + " == " + default["remote"])
// Log.verbose(" remote=" + str(remote))
// Log.verbose(" default=" + str(default))
// if remote["name"] == default["remote"]:
// conf.select_remote = copy.deepcopy(remote)
// Log.debug(" copy select=" + str(conf.select_remote))
//
// // copy the submodule synchronisation
// conf.select_remote["sync"] = default["sync"]
// break
// if conf.select_remote == None:
// Log.error("missing remote for project: " + str(conf.name))
//
// conf.branch = default["revision"]
// out.append(conf)
// // create a temporary variable to transmit the remote to includes
// upper_remotes_forward = copy.deepcopy(upper_remotes)
// for remote in this.remotes:
// upper_remotes_forward.append(remote)
// // add all include project
// for elem in this.includes:
// list_project = elem["manifest"].get_all_configs(default, upper_remotes_forward)
// for elem_proj in list_project:
// out.append(elem_proj)
//
// //# -------------------------------------------------------------
// //# -- add Volatile ...
// //# -------------------------------------------------------------
// Log.verbose("include volatile config")
// // TODO: maybe find a better way to do this...
// conf_global = config.get_unique_config()
// for elem in conf_global.get_volatile():
// conf = repo_config.RepoConfig()
// base_volatile, repo_volatile = repo_config.split_repo(elem["git_address"])
// conf.name = repo_volatile
// conf.path = elem["path"]
// conf.branch = "master"
// conf.volatile = true
// conf.remotes = [
// {
// 'name': 'origin',
// 'fetch': base_volatile,
// 'mirror': []
// }
// ]
// conf.select_remote = {
// 'name': 'origin',
// 'fetch': base_volatile,
// 'sync': false,
// 'mirror': []
// }
// out.append(conf)
// //# -------------------------------------------------------------
// if false:
// Log.info("list of all repo:")
// for elem in out:
// Log.info(" '" + elem.name + "'")
// Log.info(" path: " + elem.path)
// Log.info(" remotes: " + str(elem.remotes))
// Log.info(" select_remote: " + str(elem.select_remote))
// Log.info(" branch: " + elem.branch)
// return out
//
//
//public void tag_manifest(manifest_xml_filename, all_tags):
// tree = etree.parse(manifest_xml_filename)
// Log.debug("manifest : '" + manifest_xml_filename + "'")
// root = tree.getroot()
// includes = []
// if root.tag != "manifest":
// Log.error("(l:" + str(child.sourceline) + ") in '" + str(file) + "' have not main xml node='manifest'")
// return false
// for child in root:
// if type(child) == etree._Comment:
// Log.verbose("(l:" + str(child.sourceline) + ") comment='" + str(child.text) + "'");
// continue
// if child.tag == "remote":
// continue
// if child.tag == "include":
// name = ""
// for attr in child.attrib:
// if attr == "name":
// name = child.attrib[attr]
// else:
// Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name]")
// Log.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "'");
// // check if the file exist ...
// new_name_xml = new Path(os.path.dirname(manifest_xml_filename),name)
// if os.path.exists(new_name_xml) == false:
// Log.error("(l:" + str(child.sourceline) + ") The file does not exist : '" + new_name_xml + "'")
// includes.append({
// "name":name,
// "path":new_name_xml,
// "manifest":None
// })
// continue
// if child.tag == "default":
// continue
// if child.tag == "project":
// name = ""
// path = ""
// tag_sha1 = None
// for attr in child.attrib:
// if attr == "name":
// name = child.attrib[attr]
// } else if attr == "path":
// path = child.attrib[attr]
// } else if attr == "tag":
// tag_sha1 = child.attrib[attr]
// else:
// Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name,tag,sync-s]")
// if name == "":
// Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'name' ==> specify the git to clone ...")
// for elem_tag in all_tags:
// if elem_tag["name"] == name:
// child.set("tag", elem_tag["tag"])
// continue
// if child.tag == "option":
// // not managed ==> future use
// continue
// if child.tag == "link":
// continue
// Log.info("(l:" + str(child.sourceline) + ") '" + str(child.tag) + "' values=" + str(child.attrib));
// Log.error("(l:" + str(child.sourceline) + ") Parsing error Unknow NODE : '" + str(child.tag) + "' availlable:[remote,include,default,project,option,link]")
// tree.write(manifest_xml_filename, pretty_print=true, xml_declaration=true, encoding="utf-8")
// // now we parse all sub repo:
// for elem in includes:
// tag_manifest(elem["path"], all_tags)
//
//
//
//public void tag_clear(manifest_xml_filename):
// tree = etree.parse(manifest_xml_filename)
// Log.debug("manifest : '" + manifest_xml_filename + "'")
// root = tree.getroot()
// includes = []
// if root.tag != "manifest":
// Log.error("(l:" + str(child.sourceline) + ") in '" + str(file) + "' have not main xml node='manifest'")
// return false
// for child in root:
// if type(child) == etree._Comment:
// Log.verbose("(l:" + str(child.sourceline) + ") comment='" + str(child.text) + "'");
// continue
// if child.tag == "remote":
// continue
// if child.tag == "include":
// name = ""
// for attr in child.attrib:
// if attr == "name":
// name = child.attrib[attr]
// else:
// Log.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name]")
// Log.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "'");
// // check if the file exist ...
// new_name_xml = new Path(os.path.dirname(manifest_xml_filename),name)
// if os.path.exists(new_name_xml) == false:
// Log.error("(l:" + str(child.sourceline) + ") The file does not exist : '" + new_name_xml + "'")
// includes.append({
// "name":name,
// "path":new_name_xml,
// "manifest":None
// })
// continue
// if child.tag == "default":
// continue
// if child.tag == "project":
// child.attrib.pop("tag", None)
// continue
// if child.tag == "option":
// continue
// if child.tag == "link":
// continue
// Log.info("(l:" + str(child.sourceline) + ") '" + str(child.tag) + "' values=" + str(child.attrib));
// Log.error("(l:" + str(child.sourceline) + ") Parsing error Unknow NODE : '" + str(child.tag) + "' availlable:[remote,include,default,project,option,link]")
// tree.write(manifest_xml_filename, pretty_print=true, xml_declaration=true, encoding="utf-8")
// // now we parse all sub repo:
// for elem in includes:
// tag_clear(elem["path"])
//

View File

@ -1,79 +0,0 @@
package org.atriasoft.island.actions;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import org.atriasoft.death.ArgElement;
import org.atriasoft.death.Arguments;
import org.atriasoft.island.Config;
import org.atriasoft.island.Env;
import org.atriasoft.island.Manifest;
import org.atriasoft.island.internal.Log;
import org.atriasoft.island.model.ActionException;
import org.atriasoft.island.model.ActionInterface;
import org.atriasoft.island.model.ConfigManifest;
public class islandActionCheckout implements ActionInterface {
@Override
public String help() {
return "Ckeckout a specific branch in all repository";
}
@Override
public void add_specific_arguments(Arguments myArgs, String section) {
myArgs.add("r", "remote", null, "Name of the remote server", true);
myArgs.addArg("branch", false, "Branch to checkout (if '__TAG__' ==> checkout specific repository tags)");
}
@Override
public String helpExample() {
// TODO Auto-generated method stub
return null;
}
@Override
public void execute(List<ArgElement> _arguments) throws ActionException {
String argument_remote_name = "";
String branch_to_checkout = "";
for (ArgElement elem : _arguments) {
if (elem.getOptionName().equals("remote")) {
Log.info("find remote name: '" + elem.getArg() + "'");
argument_remote_name = elem.getArg();
} else if (elem.getOptionName().equals("branch")) {
branch_to_checkout = elem.getArg()
} else {
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'");
return;
}
}
// check system is OK
Manifest.checkIsInit();
ConfigManifest configuration = Config.getUniqueConfig();
// update the local configuration file:
configuration.setBranch(branch_to_checkout);
configuration.store();
Path file_source_manifest = Env.get_island_path_manifest().resolve(configuration.getManifestName());
if (!Files.exists(file_source_manifest)) {
Log.critical("Missing manifest file : '" + file_source_manifest.toAbsolutePath() + "'");
}
Manifest mani = new Manifest(file_source_manifest);
all_project = mani.getAllConfigs();
Log.info("checkout of: " + str(len(all_project)) + " projects")
id_element = 0
have_error = false
for elem in all_project:
id_element += 1
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
if status.checkout_elem(elem, argument_remote_name, branch_to_checkout, base_display) == false:
have_error = true
if have_error == true:
return env.ret_action_fail
}
}

View File

@ -1,30 +0,0 @@
//#
//# @brief Get the global description of the current action
//# @return (string) the description string (fist line if reserved for the overview, all is for the specific display)
//#
public void help():
return
//#
//# @brief Add argument to the specific action
//# @param[in,out] my_args (death.Arguments) Argument manager
//# @param[in] section Name of the currect action
//#
public void add_specific_arguments(my_args, section):
//#
//# @brief Execute the action required.
//#
//# @return error value [0 .. 50] the <0 value is reserved system ==> else, what you want.
//# None : No error (return program out 0)
//# -10 : ACTION is not existing
//# -11 : ACTION execution system error
//# -12 : ACTION Wrong parameters
//#
public void execute(_arguments):

View File

@ -1,10 +1,5 @@
package org.atriasoft.island.model; package org.atriasoft.island.model;
import java.util.List;
import org.atriasoft.death.ArgElement;
import org.atriasoft.death.Arguments;
public interface ActionInterface { public interface ActionInterface {
/** /**
* Get the global description of the current action * Get the global description of the current action
@ -44,7 +39,7 @@ public interface ActionInterface {
* -11 : ACTION execution system error * -11 : ACTION execution system error
* -12 : ACTION Wrong parameters * -12 : ACTION Wrong parameters
*/ */
public void execute(List<ArgElement> _arguments) throws ActionException; public void execute(Arguments _arguments) throws ActionException;
String helpExample(); String helpExample();

View File

@ -1,204 +0,0 @@
package org.atriasoft.island.model;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import org.atriasoft.exml.Exml;
import org.atriasoft.exml.exception.ExmlBuilderException;
import org.atriasoft.island.Env;
import org.atriasoft.island.internal.Log;
public class ConfigManifest {
private String repo = "";
private String branch = "master";
private String manifestName = "default.xml";
private List<Volatile> volatiles = new ArrayList<>();
private List<Link> curentLink = new ArrayList<>();
public ConfigManifest() {
}
public String getRepo() {
return repo;
}
public void setRepo(String repo) {
this.repo = repo;
}
public String getBranch() {
return branch;
}
public void setBranch(String branch) {
this.branch = branch;
}
public String getManifestName() {
return manifestName;
}
public void setManifestName(String manifestName) {
this.manifestName = manifestName;
}
public List<Volatile> getVolatiles() {
return volatiles;
}
public void setVolatiles(List<Volatile> volatiles) {
this.volatiles = volatiles;
}
public void addVolatile(String gitAddress, String path) {
rmVolatile(path);
this.volatiles.add(new Volatile(gitAddress, path));
}
private void rmVolatile(String path) {
ListIterator<Volatile> it = volatiles.listIterator();
while (it.hasNext()) {
Volatile elem = it.next();
if (elem.path.equals(path)) {
it.remove();
}
}
}
public List<Link> getCurentLink() {
return curentLink;
}
public void setCurentLink(List<Link> curentLink) {
this.curentLink = curentLink;
}
public void addLink(String source, String destination) {
rmLink(destination);
this.curentLink.add(new Link(source, destination));
}
private void rmLink(String destination) {
ListIterator<Link> it = curentLink.listIterator();
while (it.hasNext()) {
Link elem = it.next();
if (elem.destination.equals(destination)) {
it.remove();
}
}
}
public static ConfigManifest load() {
return load(Env.get_island_path_config());
}
public static ConfigManifest load(Path path) {
ConfigManifest[] root = null;
try {
root = Exml.parse(path, ConfigManifest.class, "config-island");
} catch (ExmlBuilderException e) {
Log.error("Can not parse the file.1. " + path);
e.printStackTrace();
}
if (root.length != 1) {
Log.error("Can not parse the file.2. " + path);
}
return root[0];
}
public void store() {
store(Env.get_island_path_config());
}
public void store(Path path) {
Log.todo("unimplemented model...");
}
}
// public void load():
// // transform the old format of configuration (use json now ==> simple
// if os.path.exists(env.get_island_path_config_old()) == true:
// self.convert_config_file()
// if os.path.exists(env.get_island_path_config()) == false:
// return true
// this.volatiles = []
// this.curentLink = []
// with open(env.get_island_path_config()) as json_file:
// data = json.load(json_file)
// if "repo" in data.keys():
// this.repo = data["repo"]
// if "branch" in data.keys():
// this.branch = data["branch"]
// if "manifest_name" in data.keys():
// this.manifestName = data["manifest_name"]
// if "volatiles" in data.keys():
// for elem in data["
// self.add_volatile(elem["git_address"], elem["path"])
// if "link" in data.keys():
// for elem in data["link"]:
// if "source" in elem.keys() and "destination" in elem.keys():
// self.add_link(elem["source"], elem["destination"])
// return true
// return false
//
// public void store(self):
// data = {}
// data["repo"] = this.repo
// data["branch"] = this.branch
// data["manifest_name"] = this.manifestName
// data["volatiles"] = this.volatiles
// data["link"] = this.curentLink
// with open(env.get_island_path_config(), 'w') as outfile:
// json.dump(data, outfile, indent=4)
// return true
// return false
//
// public void add_volatile(self, git_adress, local_path):
// for elem in this.volatiles:
// if elem["path"] == local_path:
// Log.error("can not have multiple local repositoty on the same PATH", crash=false)
// return false
// this.volatiles.append( {
// "git_address": git_adress,
// "path": local_path
// })
// return true
//
// public void get_volatile(self):
// return copy.deepcopy(this.volatiles)
//
//
// public void get_links(self):
// return this.curentLink
//
// public void add_link(self, source, destination):
// for elem in this.curentLink:
// if elem["destination"] == destination:
// Log.error("can not have multiple destination folder in link " + destination, crash=false)
// return false
// this.curentLink.append( {
// "source": source,
// "destination": destination
// })
// return true
//
// public void remove_link(self, destination):
// for elem in this.curentLink:
// if elem["destination"] == destination:
// del this.curentLink[elem]
// return
// Log.warning("Request remove link that does not exist")
//
// public void clear_links(self):
// this.curentLink = []
//
//
// public void get_manifest_config(self):
// conf = repo_config.RepoConfig()
// base_volatile, repo_volatile = repo_config.split_repo(self.get_manifest())
// conf.name = repo_volatile
// conf.path = new Path("." + env.get_system_base_name(), "manifest") //env.get_island_path_manifest()
// conf.branch = "master"
// conf.volatile = false
// conf.remotes = [
// {
// 'name': 'origin',
// 'fetch': base_volatile,
// 'mirror': []
// }
// ]
// conf.select_remote = {
// 'name': 'origin',
// 'fetch': base_volatile,
// 'sync': false,
// 'mirror': []
// }
// return conf

View File

@ -1,15 +0,0 @@
package org.atriasoft.island.model;
class Link {
public String source;
public String destination;
public Link(String source, String destination) {
this.source = source;
this.destination = destination;
}
public Link() {
this.source = "";
this.destination = "";
}
}

View File

@ -1,10 +0,0 @@
package org.atriasoft.island.model;
class Volatile {
public String gitAddress;
public String path;
public Volatile(String gitAddress, String path) {
this.gitAddress = gitAddress;
this.path = path;
}
}

View 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
from island import commands
import status
import os
//#
//# @brief Get the global description of the current action
//# @return (string) the description string (fist line if reserved for the overview, all is for the specific display)
//#
public void help():
return "Ckeckout a specific branch in all repository"
//#
//# @brief Add argument to the specific action
//# @param[in,out] my_args (death.Arguments) Argument manager
//# @param[in] section Name of the currect action
//#
public void 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 (if '__TAG__' ==> checkout specific repository tags)")
//#
//# @brief Execute the action required.
//#
//# @return error value [0 .. 50] the <0 value is reserved system ==> else, what you want.
//# None : No error (return program out 0)
//# -10 : ACTION is not existing
//# -11 : ACTION execution system error
//# -12 : ACTION Wrong parameters
//#
public void execute(_arguments):
argument_remote_name = ""
branch_to_checkout = ""
for elem in _arguments:
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() + "'")
// check system is OK
manifest.check_lutin_is_init()
configuration = config.get_unique_config()
// update the local configuration file:
configuration.set_branch(branch_to_checkout)
configuration.store()
file_source_manifest = new Path(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("checkout of: " + str(len(all_project)) + " projects")
id_element = 0
have_error = false
for elem in all_project:
id_element += 1
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
if status.checkout_elem(elem, argument_remote_name, branch_to_checkout, base_display) == false:
have_error = true
if have_error == true:
return env.ret_action_fail

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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
@ -44,8 +44,8 @@ public void have_unknow_argument():
public void execute(_arguments): public void execute(_arguments):
cmd = "" cmd = ""
for elem in _arguments: for elem in _arguments:
Log.info("Get data element: " + str(elem.getArg())) debug.info("Get data element: " + str(elem.get_arg()))
cmd += elem.getArg() + " " cmd += elem.get_arg() + " "
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()
@ -54,30 +54,30 @@ public void execute(_arguments):
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name()) file_source_manifest = new Path(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:
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'") debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
mani = manifest.Manifest(file_source_manifest) mani = manifest.Manifest(file_source_manifest)
all_project = mani.get_all_configs() all_project = mani.get_all_configs()
Log.info("status of: " + str(len(all_project)) + " projects") debug.info("status of: " + str(len(all_project)) + " projects")
id_element = 0 id_element = 0
for elem in all_project: for elem in all_project:
Log.info("------------------------------------------") debug.info("------------------------------------------")
id_element += 1 id_element += 1
base_display = tools.get_list_base_display(id_element, len(all_project), elem) base_display = tools.get_list_base_display(id_element, len(all_project), elem)
Log.info("execute command : " + base_display) debug.info("execute command : " + base_display)
tools.wait_for_server_if_needed() tools.wait_for_server_if_needed()
//Log.debug("elem : " + str(elem)) //debug.debug("elem : " + str(elem))
git_repo_path = new Path(env.get_island_root_path(), elem.path) git_repo_path = new Path(env.get_island_root_path(), elem.path)
if os.path.exists(git_repo_path) == false: if os.path.exists(git_repo_path) == false:
Log.info("" + base_display + "\r\t\t\t\t\t\t\t\t\t" + " (not download)") debug.info("" + base_display + "\r\t\t\t\t\t\t\t\t\t" + " (not download)")
continue continue
Log.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[0] == 0: if ret[0] == 0:
Log.info("ret=" + ret[1]) debug.info("ret=" + ret[1])
Log.info("err=" + ret[2]) debug.info("err=" + ret[2])
else: else:
Log.info("Execution ERROR") debug.info("Execution ERROR")

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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 config
@ -49,15 +49,15 @@ public void execute(_arguments):
argument_amend = "" argument_amend = ""
argument_all = "" argument_all = ""
for elem in _arguments: for elem in _arguments:
if elem.getOptionName() == "message": if elem.get_option_name() == "message":
Log.info("find message: '" + elem.getArg() + "'") debug.info("find message: '" + elem.get_arg() + "'")
argument_message = " --message \"" + elem.getArg() + "\" "; argument_message = " --message \"" + elem.get_arg() + "\" ";
} else if elem.getOptionName() == "all": elif elem.get_option_name() == "all":
argument_all = " --all " argument_all = " --all "
} else if elem.getOptionName() == "amend": elif elem.get_option_name() == "amend":
argument_amend = " --amend " argument_amend = " --amend "
else: else:
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()
@ -66,30 +66,30 @@ public void execute(_arguments):
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name()) file_source_manifest = new Path(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:
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'") debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
mani = manifest.Manifest(file_source_manifest) mani = manifest.Manifest(file_source_manifest)
all_project = mani.get_all_configs() all_project = mani.get_all_configs()
Log.info("commit : " + str(len(all_project)) + " projects") debug.info("commit : " + str(len(all_project)) + " projects")
id_element = 0 id_element = 0
for elem in all_project: for elem in all_project:
id_element += 1 id_element += 1
base_display = tools.get_list_base_display(id_element, len(all_project), elem) base_display = tools.get_list_base_display(id_element, len(all_project), elem)
Log.info("commit: " + base_display) debug.info("commit: " + base_display)
git_repo_path = new Path(env.get_island_root_path(), elem.path) git_repo_path = new Path(env.get_island_root_path(), elem.path)
if os.path.exists(git_repo_path) == false: if os.path.exists(git_repo_path) == false:
Log.error("can not commit project that not exist") debug.error("can not commit project that not exist")
continue continue
if os.path.exists(new Path(git_repo_path,".git")) == false: if os.path.exists(new Path(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
Log.warning("path '" + git_repo_path + "' is already existing but not used for a git repository. Clean it and restart") debug.warning("path '" + git_repo_path + "' is already existing but not used for a git repository. Clean it and restart")
continue; continue;
// simply update the repository ... // simply update the repository ...
Log.verbose("commit in project:") debug.verbose("commit in project:")
// fetch the repository // fetch the repository
cmd = "git commit " + argument_amend + argument_all + argument_message cmd = "git commit " + argument_amend + argument_all + argument_message
Log.debug("execute : " + cmd) debug.debug("execute : " + cmd)
multiprocess.run_command_direct(cmd, cwd=git_repo_path) multiprocess.run_command_direct(cmd, cwd=git_repo_path)

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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 config
@ -45,11 +45,11 @@ public void add_specific_arguments(my_args, section):
public void execute(_arguments): public void execute(_arguments):
argument_remote_name = "" argument_remote_name = ""
for elem in _arguments: for elem in _arguments:
if elem.getOptionName() == "remote": if elem.get_option_name() == "remote":
Log.info("find remote name: '" + elem.getArg() + "'") debug.info("find remote name: '" + elem.get_arg() + "'")
argument_remote_name = elem.getArg() argument_remote_name = elem.get_arg()
else: else:
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()
@ -58,14 +58,14 @@ public void execute(_arguments):
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name()) file_source_manifest = new Path(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:
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'") debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
mani = manifest.Manifest(file_source_manifest) mani = manifest.Manifest(file_source_manifest)
destination_branch = mani.deliver_master destination_branch = mani.deliver_master
source_branch = mani.deliver_develop source_branch = mani.deliver_develop
all_project = mani.get_all_configs() all_project = mani.get_all_configs()
Log.info("fetch : " + str(len(all_project)) + " projects") debug.info("fetch : " + str(len(all_project)) + " projects")
id_element = 0 id_element = 0
for elem in all_project: for elem in all_project:
id_element += 1 id_element += 1
@ -73,7 +73,7 @@ public void execute(_arguments):
if argument_remote_name == "": if argument_remote_name == "":
argument_remote_name = elem.select_remote["name"] argument_remote_name = elem.select_remote["name"]
base_display = tools.get_list_base_display(id_element, len(all_project), elem) base_display = tools.get_list_base_display(id_element, len(all_project), elem)
Log.info("deliver-push: " + base_display) debug.info("deliver-push: " + base_display)
tools.wait_for_server_if_needed() tools.wait_for_server_if_needed()
status.deliver_push(elem, argument_remote_name, destination_branch, source_branch, base_display) status.deliver_push(elem, argument_remote_name, destination_branch, source_branch, base_display)

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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
@ -48,14 +48,14 @@ public void execute(_arguments):
argument_from = None argument_from = None
argument_to = None argument_to = None
for elem in _arguments: for elem in _arguments:
if elem.getOptionName() == "from": if elem.get_option_name() == "from":
Log.info("find source branch name: '" + elem.getArg() + "'") debug.info("find source branch name: '" + elem.get_arg() + "'")
argument_from = elem.getArg() argument_from = elem.get_arg()
} else if elem.getOptionName() == "to": elif elem.get_option_name() == "to":
Log.info("find destination branch name: '" + elem.getArg() + "'") debug.info("find destination branch name: '" + elem.get_arg() + "'")
argument_to = elem.getArg() argument_to = elem.get_arg()
else: else:
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()
@ -64,7 +64,7 @@ public void execute(_arguments):
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name()) file_source_manifest = new Path(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:
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'") debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
mani = manifest.Manifest(file_source_manifest) mani = manifest.Manifest(file_source_manifest)
@ -76,33 +76,33 @@ public void execute(_arguments):
destination_branch = argument_to destination_branch = argument_to
all_project = mani.get_all_configs() all_project = mani.get_all_configs()
Log.info("Check if all project are on master: " + str(len(all_project)) + " projects") debug.info("Check if all project are on master: " + str(len(all_project)) + " projects")
id_element = 0 id_element = 0
deliver_availlable = true deliver_availlable = true
for elem in all_project: for elem in all_project:
id_element += 1 id_element += 1
base_display = tools.get_list_base_display(id_element, len(all_project), elem) base_display = tools.get_list_base_display(id_element, len(all_project), elem)
Log.verbose("deliver-ckeck: " + base_display) debug.verbose("deliver-ckeck: " + base_display)
if status.deliver_check(elem, argument_remote_name, id_element, base_display, source_branch, destination_branch) == false: if status.deliver_check(elem, argument_remote_name, id_element, base_display, source_branch, destination_branch) == false:
deliver_availlable = false deliver_availlable = false
if deliver_availlable == false: if deliver_availlable == false:
Log.error("deliver-ckeck: Correct the warning to validate the Merge") debug.error("deliver-ckeck: Correct the warning to validate the Merge")
return return
Log.info("deliver-ckeck: ==> All is OK") debug.info("deliver-ckeck: ==> All is OK")
id_element = 0 id_element = 0
for elem in all_project: for elem in all_project:
id_element += 1 id_element += 1
base_display = tools.get_list_base_display(id_element, len(all_project), elem) base_display = tools.get_list_base_display(id_element, len(all_project), elem)
Log.info("deliver: ========================================================================") debug.info("deliver: ========================================================================")
Log.info("deliver: == " + base_display) debug.info("deliver: == " + base_display)
Log.info("deliver: ========================================================================") debug.info("deliver: ========================================================================")
git_repo_path = new Path(env.get_island_root_path(), elem.path) git_repo_path = new Path(env.get_island_root_path(), elem.path)
// Check the validity of the version, // Check the validity of the version,
version_description, add_in_version_management = status.get_current_version_repo(git_repo_path) version_description, add_in_version_management = status.get_current_version_repo(git_repo_path)
if version_description == None: if version_description == None:
continue continue
Log.info("deliver: ==> version: " + str(version_description)) debug.info("deliver: ==> version: " + str(version_description))
// go to the dev branch // go to the dev branch
select_branch = commands.get_current_branch(git_repo_path) select_branch = commands.get_current_branch(git_repo_path)
@ -112,7 +112,7 @@ public void execute(_arguments):
// create new repo tag // create new repo tag
new_version_description = status.create_new_version_repo(git_repo_path, version_description, add_in_version_management, source_branch, destination_branch) new_version_description = status.create_new_version_repo(git_repo_path, version_description, add_in_version_management, source_branch, destination_branch)
Log.info("new version: " + str(new_version_description)) debug.info("new version: " + str(new_version_description))
if new_version_description == None: if new_version_description == None:
continue continue
// merge branch // merge branch

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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 config
@ -45,26 +45,26 @@ public void add_specific_arguments(my_args, section):
public void execute(_arguments): public void execute(_arguments):
argument_remote_name = "" argument_remote_name = ""
for elem in _arguments: for elem in _arguments:
if elem.getOptionName() == "remote": if elem.get_option_name() == "remote":
Log.info("find remote name: '" + elem.getArg() + "'") debug.info("find remote name: '" + elem.get_arg() + "'")
argument_remote_name = elem.getArg() argument_remote_name = elem.get_arg()
else: else:
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()
Log.info("fetch manifest : '" + str(env.get_island_path_manifest()) + "'") debug.info("fetch manifest : '" + str(env.get_island_path_manifest()) + "'")
commands.fetch(env.get_island_path_manifest(), "origin") commands.fetch(env.get_island_path_manifest(), "origin")
configuration = config.get_unique_config() configuration = config.get_unique_config()
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name()) file_source_manifest = new Path(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:
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'") debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
mani = manifest.Manifest(file_source_manifest) mani = manifest.Manifest(file_source_manifest)
all_project = mani.get_all_configs() all_project = mani.get_all_configs()
Log.info("fetch : " + str(len(all_project)) + " projects") debug.info("fetch : " + str(len(all_project)) + " projects")
id_element = 0 id_element = 0
for elem in all_project: for elem in all_project:
id_element += 1 id_element += 1
@ -73,20 +73,20 @@ public void execute(_arguments):
argument_remote_name = elem.select_remote["name"] argument_remote_name = elem.select_remote["name"]
base_display = tools.get_list_base_display(id_element, len(all_project), elem) base_display = tools.get_list_base_display(id_element, len(all_project), elem)
Log.info("fetch: " + base_display) debug.info("fetch: " + base_display)
tools.wait_for_server_if_needed() tools.wait_for_server_if_needed()
//Log.debug("elem : " + str(elem)) //debug.debug("elem : " + str(elem))
git_repo_path = new Path(env.get_island_root_path(), elem.path) git_repo_path = new Path(env.get_island_root_path(), elem.path)
if os.path.exists(git_repo_path) == false: if os.path.exists(git_repo_path) == false:
Log.error("can not fetch project that not exist") debug.error("can not fetch project that not exist")
continue continue
if os.path.exists(new Path(git_repo_path,".git")) == false: if os.path.exists(new Path(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
Log.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")
// simply update the repository ... // simply update the repository ...
Log.verbose("Fetching project: ") debug.verbose("Fetching project: ")
commands.fetch(git_repo_path, argument_remote_name) commands.fetch(git_repo_path, argument_remote_name)

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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 config
@ -44,35 +44,35 @@ public void add_specific_arguments(my_args, section):
//# //#
public void execute(_arguments): public void execute(_arguments):
if len(_arguments) == 0: if len(_arguments) == 0:
Log.error("Missing argument to execute the current action ...") debug.error("Missing argument to execute the current action ...")
// the configuration availlable: // the configuration availlable:
branch = "master" branch = "master"
manifest_name = "default.xml" manifest_name = "default.xml"
address_manifest = "" address_manifest = ""
for elem in _arguments: for elem in _arguments:
if elem.getOptionName() == "branch": if elem.get_option_name() == "branch":
Log.info("find branch name: '" + elem.getArg() + "'") debug.info("find branch name: '" + elem.get_arg() + "'")
branch = elem.getArg() branch = elem.get_arg()
} else if elem.getOptionName() == "manifest": elif elem.get_option_name() == "manifest":
Log.info("find mmanifest name: '" + elem.getArg() + "'") debug.info("find mmanifest name: '" + elem.get_arg() + "'")
manifest_name = elem.getArg() manifest_name = elem.get_arg()
} else if elem.getOptionName() == "": elif elem.get_option_name() == "":
if address_manifest != "": if address_manifest != "":
Log.error("Manifest adress already set : '" + address_manifest + "' !!! '" + elem.getArg() + "'") debug.error("Manifest adress already set : '" + address_manifest + "' !!! '" + elem.get_arg() + "'")
address_manifest = elem.getArg() address_manifest = elem.get_arg()
else: else:
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
if address_manifest == "": if address_manifest == "":
Log.error("Init: Missing manifest name") debug.error("Init: Missing manifest name")
Log.info("Init with: '" + address_manifest + "' branch='" + branch + "' name of manifest='" + manifest_name + "'") debug.info("Init with: '" + address_manifest + "' branch='" + branch + "' name of manifest='" + manifest_name + "'")
// check if .XXX exist (create it if needed) // check if .XXX exist (create it if needed)
if manifest.is_lutin_init() == true: if manifest.is_lutin_init() == true:
Log.error("System already init: path already exist: '" + str(env.get_island_path()) + "'") debug.error("System already init: path already exist: '" + str(env.get_island_path()) + "'")
tools.create_directory(env.get_island_path()) tools.create_directory(env.get_island_path())
// check if the git of the manifest if availlable // check if the git of the manifest if availlable
@ -84,15 +84,15 @@ public void execute(_arguments):
conf.set_manifest_name(manifest_name) conf.set_manifest_name(manifest_name)
conf.store() conf.store()
Log.info("Clone the manifest") debug.info("Clone the manifest")
ret_values = commands.clone(env.get_island_path_manifest(), address_manifest, branch_name=branch) ret_values = commands.clone(env.get_island_path_manifest(), address_manifest, branch_name=branch)
if ret_values == false: if ret_values == false:
Log.info("'" + str(ret_values) + "'") debug.info("'" + str(ret_values) + "'")
Log.error("Init does not work") debug.error("Init does not work")
return false return false
Log.info("Init done correctly ...") debug.info("Init done correctly ...")
return None return None

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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 config
@ -48,13 +48,13 @@ public void execute(_arguments):
argument_remote_name = "" argument_remote_name = ""
branch_to_checkout = "" branch_to_checkout = ""
for elem in _arguments: for elem in _arguments:
if elem.getOptionName() == "remote": if elem.get_option_name() == "remote":
Log.info("find remote name: '" + elem.getArg() + "'") debug.info("find remote name: '" + elem.get_arg() + "'")
argument_remote_name = elem.getArg() argument_remote_name = elem.get_arg()
} else if elem.getOptionName() == "branch": elif elem.get_option_name() == "branch":
branch_to_checkout = elem.getArg() branch_to_checkout = elem.get_arg()
else: else:
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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 config
@ -45,7 +45,7 @@ public void add_specific_arguments(my_args, section):
//# //#
public void execute(_arguments): public void execute(_arguments):
for elem in _arguments: for elem in _arguments:
Log.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") debug.error("pull Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()
@ -54,7 +54,7 @@ public void execute(_arguments):
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name()) file_source_manifest = new Path(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:
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'") debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
elem = configuration.get_manifest_config() elem = configuration.get_manifest_config()

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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 config
@ -49,7 +49,7 @@ public void add_specific_arguments(my_args, section):
public void execute(_arguments): public void execute(_arguments):
argument_remote_name = "" argument_remote_name = ""
for elem in _arguments: for elem in _arguments:
Log.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") debug.error("pull Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()
@ -58,7 +58,7 @@ public void execute(_arguments):
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name()) file_source_manifest = new Path(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:
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'") debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
elem = configuration.get_manifest_config() elem = configuration.get_manifest_config()
@ -69,31 +69,31 @@ public void execute(_arguments):
// Check the manifest is up to date ... // Check the manifest is up to date ...
base_display = tools.get_list_base_display(0, 0, elem) base_display = tools.get_list_base_display(0, 0, elem)
Log.verbose("deliver-ckeck: " + base_display) debug.verbose("deliver-ckeck: " + base_display)
if status.deliver_check(elem, argument_remote_name, 0, base_display, source_branch, destination_branch) == false: if status.deliver_check(elem, argument_remote_name, 0, base_display, source_branch, destination_branch) == false:
Log.error("Can not deliver a MANIFEST that is not ready to merge", crash=false) debug.error("Can not deliver a MANIFEST that is not ready to merge", crash=false)
return env.ret_action_fail return env.ret_action_fail
all_tags = check_all_tags(mani) all_tags = check_all_tags(mani)
if all_tags == None: if all_tags == None:
Log.error("Need the Tags are set in sub-repository", crash=false) debug.error("Need the Tags are set in sub-repository", crash=false)
return env.ret_action_fail return env.ret_action_fail
// deliver the manifest (if Needed ...) // deliver the manifest (if Needed ...)
base_display = tools.get_list_base_display(0, 0, elem) base_display = tools.get_list_base_display(0, 0, elem)
Log.info("manifest-deliver: ========================================================================") debug.info("manifest-deliver: ========================================================================")
Log.info("manifest-deliver: == " + base_display) debug.info("manifest-deliver: == " + base_display)
Log.info("manifest-deliver: ========================================================================") debug.info("manifest-deliver: ========================================================================")
git_repo_path = new Path(env.get_island_root_path(), elem.path) git_repo_path = new Path(env.get_island_root_path(), elem.path)
// Check the validity of the version, // Check the validity of the version,
version_description, add_in_version_management = status.get_current_version_repo(git_repo_path) version_description, add_in_version_management = status.get_current_version_repo(git_repo_path)
if version_description == None: if version_description == None:
return env.ret_action_fail return env.ret_action_fail
Log.info("manifest-deliver: ==> version: " + str(version_description)) debug.info("manifest-deliver: ==> version: " + str(version_description))
// go to the dev branch // go to the dev branch
select_branch = commands.get_current_branch(git_repo_path) select_branch = commands.get_current_branch(git_repo_path)
@ -101,7 +101,7 @@ public void execute(_arguments):
// create new repo tag // create new repo tag
new_version_description = status.create_new_version_repo(git_repo_path, version_description, add_in_version_management, source_branch, destination_branch) new_version_description = status.create_new_version_repo(git_repo_path, version_description, add_in_version_management, source_branch, destination_branch)
Log.info("new version: " + str(new_version_description)) debug.info("new version: " + str(new_version_description))
if new_version_description == None: if new_version_description == None:
return return
// merge branch // merge branch
@ -130,13 +130,13 @@ public void execute(_arguments):
commands.checkout(git_repo_path, destination_branch) commands.checkout(git_repo_path, destination_branch)
Log.info("manifest-deliver: ==> DONE") debug.info("manifest-deliver: ==> DONE")
public void check_all_tags(mani): public void check_all_tags(mani):
all_project = mani.get_all_configs() all_project = mani.get_all_configs()
Log.info("Check all: " + str(len(all_project)) + " projects have a current tag ...") debug.info("Check all: " + str(len(all_project)) + " projects have a current tag ...")
id_element = 0 id_element = 0
check_have_error = false check_have_error = false
list_tags = [] list_tags = []
@ -144,16 +144,16 @@ public void check_all_tags(mani):
id_element += 1 id_element += 1
base_display = tools.get_list_base_display(id_element, len(all_project), elem) base_display = tools.get_list_base_display(id_element, len(all_project), elem)
if elem.volatile == true: if elem.volatile == true:
Log.info(base_display + "\r\t\t\t\t\t\t\t\t\t" + " (Not Managed)") debug.info(base_display + "\r\t\t\t\t\t\t\t\t\t" + " (Not Managed)")
continue continue
tags_comment = "" tags_comment = ""
git_repo_path = new Path(env.get_island_root_path(), elem.path) git_repo_path = new Path(env.get_island_root_path(), elem.path)
if os.path.exists(git_repo_path) == false: if os.path.exists(git_repo_path) == false:
Log.error(base_display + volatile + "\r\t\t\t\t\t\t\t\t\t" + " (not download)", crash=false) debug.error(base_display + volatile + "\r\t\t\t\t\t\t\t\t\t" + " (not download)", crash=false)
check_have_error = true check_have_error = true
continue continue
ret_current_tags = commands.get_tags_current(git_repo_path) ret_current_tags = commands.get_tags_current(git_repo_path)
Log.verbose("tags found: " + str(ret_current_tags)) debug.verbose("tags found: " + str(ret_current_tags))
if len(ret_current_tags) == 0: if len(ret_current_tags) == 0:
list_tags.append({ list_tags.append({
"name":elem.name, "name":elem.name,
@ -169,11 +169,11 @@ public void check_all_tags(mani):
tags_comment += "," tags_comment += ","
tags_comment += elem_tag tags_comment += elem_tag
if len(ret_current_tags) == 0: if len(ret_current_tags) == 0:
Log.error(base_display + "\r\t\t\t\t\t\t\t\t\t" + " (NO TAG DETECTED)", crash=false) debug.error(base_display + "\r\t\t\t\t\t\t\t\t\t" + " (NO TAG DETECTED)", crash=false)
check_have_error = true check_have_error = true
continue continue
else: else:
Log.info(base_display + "\r\t\t\t\t\t\t\t\t\t" + " " + tags_comment) debug.info(base_display + "\r\t\t\t\t\t\t\t\t\t" + " " + tags_comment)
if check_have_error == true: if check_have_error == true:
return None return None
return list_tags return list_tags

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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 config
@ -47,10 +47,10 @@ public void execute(_arguments):
argument_remote_name = "" argument_remote_name = ""
argument_display_tag = false argument_display_tag = false
for elem in _arguments: for elem in _arguments:
if elem.getOptionName() == "tags": if elem.get_option_name() == "tags":
argument_display_tag = true argument_display_tag = true
else: else:
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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 config
@ -44,14 +44,14 @@ public void add_specific_arguments(my_args, section):
//# //#
public void execute(_arguments): public void execute(_arguments):
for elem in _arguments: for elem in _arguments:
Log.error("pull Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") debug.error("pull Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()
configuration = config.get_unique_config() configuration = config.get_unique_config()
Log.info("update manifest : '" + str(env.get_island_path_manifest()) + "'") debug.info("update manifest : '" + str(env.get_island_path_manifest()) + "'")
is_modify_manifest = commands.check_repository_is_modify(env.get_island_path_manifest()) is_modify_manifest = commands.check_repository_is_modify(env.get_island_path_manifest())
if is_modify_manifest == true: if is_modify_manifest == true:
commands.fetch(env.get_island_path_manifest(), "origin") commands.fetch(env.get_island_path_manifest(), "origin")

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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 config
@ -45,11 +45,11 @@ public void add_specific_arguments(_my_args, _section):
public void execute(_arguments): public void execute(_arguments):
argument_remote_name = "" argument_remote_name = ""
for elem in _arguments: for elem in _arguments:
if elem.getOptionName() == "remote": if elem.get_option_name() == "remote":
Log.info("find remote name: '" + elem.getArg() + "'") debug.info("find remote name: '" + elem.get_arg() + "'")
argument_remote_name = elem.getArg() argument_remote_name = elem.get_arg()
else: else:
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()
@ -58,31 +58,31 @@ public void execute(_arguments):
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name()) file_source_manifest = new Path(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:
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'") debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
mani = manifest.Manifest(file_source_manifest) mani = manifest.Manifest(file_source_manifest)
all_project = mani.get_all_configs() all_project = mani.get_all_configs()
Log.info("fetch : " + str(len(all_project)) + " projects") debug.info("fetch : " + str(len(all_project)) + " projects")
id_element = 0 id_element = 0
for elem in all_project: for elem in all_project:
id_element += 1 id_element += 1
base_display = tools.get_list_base_display(id_element, len(all_project), elem) base_display = tools.get_list_base_display(id_element, len(all_project), elem)
Log.info("push: " + base_display) debug.info("push: " + base_display)
tools.wait_for_server_if_needed() tools.wait_for_server_if_needed()
//Log.debug("elem : " + str(elem)) //debug.debug("elem : " + str(elem))
git_repo_path = new Path(env.get_island_root_path(), elem.path) git_repo_path = new Path(env.get_island_root_path(), elem.path)
if os.path.exists(git_repo_path) == false: if os.path.exists(git_repo_path) == false:
Log.error("can not push project that not exist") debug.error("can not push project that not exist")
continue continue
if os.path.exists(new Path(git_repo_path,".git")) == false: if os.path.exists(new Path(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
Log.error("path '" + git_repo_path + "' exist but not used for a git repository. Clean it and restart") debug.error("path '" + git_repo_path + "' exist but not used for a git repository. Clean it and restart")
// get the current branch: // get the current branch:
// get local branch // get local branch
cmd = "git branch -a" cmd = "git branch -a"
Log.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)
list_branch = ret_branch[1].split('\n') list_branch = ret_branch[1].split('\n')
list_branch2 = [] list_branch2 = []
@ -101,7 +101,7 @@ public void execute(_arguments):
list_branch3.append(elem_branch[2:]) list_branch3.append(elem_branch[2:])
// simply update the repository ... // simply update the repository ...
Log.verbose("Push project: ") debug.verbose("Push project: ")
// fetch the repository // fetch the repository
cmd = "git push" cmd = "git push"
if argument_remote_name != "": if argument_remote_name != "":
@ -109,6 +109,6 @@ public void execute(_arguments):
else: else:
cmd += " " + elem.select_remote["name"] cmd += " " + elem.select_remote["name"]
cmd += " " + select_branch + ":" + select_branch cmd += " " + select_branch + ":" + select_branch
Log.info("execute : " + cmd) debug.info("execute : " + cmd)
multiprocess.run_command_direct(cmd, cwd=git_repo_path) multiprocess.run_command_direct(cmd, cwd=git_repo_path)

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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
@ -48,13 +48,13 @@ public void execute(_arguments):
argument_remote_name = "" argument_remote_name = ""
argument_display_tag = false argument_display_tag = false
for elem in _arguments: for elem in _arguments:
if elem.getOptionName() == "remote": if elem.get_option_name() == "remote":
Log.info("find remote name: '" + elem.getArg() + "'") debug.info("find remote name: '" + elem.get_arg() + "'")
argument_remote_name = elem.getArg() argument_remote_name = elem.get_arg()
} else if elem.getOptionName() == "tags": elif elem.get_option_name() == "tags":
argument_display_tag = true argument_display_tag = true
else: else:
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()
@ -62,16 +62,16 @@ public void execute(_arguments):
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name()) file_source_manifest = new Path(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:
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'") debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
mani = manifest.Manifest(file_source_manifest) mani = manifest.Manifest(file_source_manifest)
is_modify_manifest = commands.check_repository_is_modify(env.get_island_path_manifest()) is_modify_manifest = commands.check_repository_is_modify(env.get_island_path_manifest())
if is_modify_manifest == true: if is_modify_manifest == true:
Log.info("!!!!!!!!!!!! MANIFEST is modify !!!!!!!!") debug.info("!!!!!!!!!!!! MANIFEST is modify !!!!!!!!")
all_project = mani.get_all_configs() all_project = mani.get_all_configs()
Log.info("status of: " + str(len(all_project)) + " projects") debug.info("status of: " + str(len(all_project)) + " projects")
id_element = 0 id_element = 0
elem = configuration.get_manifest_config() elem = configuration.get_manifest_config()

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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 config
@ -48,106 +48,106 @@ public void add_specific_arguments(my_args, section):
public void execute(_arguments): public void execute(_arguments):
reset_instead_of_rebase = false reset_instead_of_rebase = false
for elem in _arguments: for elem in _arguments:
if elem.getOptionName() == "rebase": if elem.get_option_name() == "rebase":
reset_instead_of_rebase = true reset_instead_of_rebase = true
Log.info("==> Request reset instead of rebase") debug.info("==> Request reset instead of rebase")
else: else:
Log.error("SYNC Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'", ret_value=env.ret_action_wrong_parameters) debug.error("SYNC Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'", ret_value=env.ret_action_wrong_parameters)
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()
configuration = config.get_unique_config() configuration = config.get_unique_config()
Log.info("update manifest : '" + str(env.get_island_path_manifest()) + "'") debug.info("update manifest : '" + str(env.get_island_path_manifest()) + "'")
is_modify_manifest = commands.check_repository_is_modify(env.get_island_path_manifest()) is_modify_manifest = commands.check_repository_is_modify(env.get_island_path_manifest())
if is_modify_manifest == true: if is_modify_manifest == true:
Log.warning("Manifest is modify") debug.warning("Manifest is modify")
else: else:
ret_track = commands.get_current_tracking_branch(env.get_island_path_manifest()) ret_track = commands.get_current_tracking_branch(env.get_island_path_manifest())
is_forward = commands.is_forward(env.get_island_path_manifest(), ret_track) is_forward = commands.is_forward(env.get_island_path_manifest(), ret_track)
if is_forward == true: if is_forward == true:
// fetch the repository // fetch the repository
Log.warning("sync-local: Not update ==> the MANIFEST is forward the remote branch " + str(commands.get_forward(env.get_island_path_manifest(), ret_track))) debug.warning("sync-local: Not update ==> the MANIFEST is forward the remote branch " + str(commands.get_forward(env.get_island_path_manifest(), ret_track)))
else: else:
Log.verbose("Check behind:") debug.verbose("Check behind:")
is_behind = commands.is_behind(env.get_island_path_manifest(), ret_track) is_behind = commands.is_behind(env.get_island_path_manifest(), ret_track)
if is_behind == false: if is_behind == false:
// fetch the repository // fetch the repository
Log.info("sync-local: MANIFEST is up-to-date") debug.info("sync-local: MANIFEST is up-to-date")
else: else:
if reset_instead_of_rebase == true: if reset_instead_of_rebase == true:
Log.info("sync-local: MANIFEST Reset to " + ret_track) debug.info("sync-local: MANIFEST Reset to " + ret_track)
commands.reset_hard(env.get_island_path_manifest(), ret_track) commands.reset_hard(env.get_island_path_manifest(), ret_track)
else: else:
Log.info("sync-local: MANIFEST Rebase to " + ret_track) debug.info("sync-local: MANIFEST Rebase to " + ret_track)
commands.rebase(env.get_island_path_manifest(), ret_track) commands.rebase(env.get_island_path_manifest(), ret_track)
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name()) file_source_manifest = new Path(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:
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'", ret_value=env.ret_manifest_is_not_existing) debug.error("Missing manifest file : '" + str(file_source_manifest) + "'", ret_value=env.ret_manifest_is_not_existing)
mani = manifest.Manifest(file_source_manifest) mani = manifest.Manifest(file_source_manifest)
all_project = mani.get_all_configs() all_project = mani.get_all_configs()
Log.info("synchronize : " + str(len(all_project)) + " projects") debug.info("synchronize : " + str(len(all_project)) + " projects")
id_element = 0 id_element = 0
count_error = 0 count_error = 0
for elem in all_project: for elem in all_project:
id_element += 1 id_element += 1
base_display = tools.get_list_base_display(id_element, len(all_project), elem) base_display = tools.get_list_base_display(id_element, len(all_project), elem)
Log.info("----------------------------------------------------------------") debug.info("----------------------------------------------------------------")
Log.info("sync-local: " + base_display) debug.info("sync-local: " + base_display)
//Log.debug("elem : " + str(elem)) //debug.debug("elem : " + str(elem))
git_repo_path = new Path(env.get_island_root_path(), elem.path) git_repo_path = new Path(env.get_island_root_path(), elem.path)
if os.path.exists(git_repo_path) == false: if os.path.exists(git_repo_path) == false:
// The Repository does not exist ==> Nothing to do... // The Repository does not exist ==> Nothing to do...
Log.warning("sync-local: ==> Not download") debug.warning("sync-local: ==> Not download")
count_error += 1 count_error += 1
continue continue
if os.path.exists(new Path(git_repo_path,".git")) == false: if os.path.exists(new Path(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
Log.warning("sync-local: is already existing but not used for a git repository. Remove it and sync") debug.warning("sync-local: is already existing but not used for a git repository. Remove it and sync")
count_error += 1 count_error += 1
continue continue
// simply update the repository ... // simply update the repository ...
Log.verbose("Check modify:") debug.verbose("Check modify:")
is_modify = commands.check_repository_is_modify(git_repo_path) is_modify = commands.check_repository_is_modify(git_repo_path)
if is_modify == true: if is_modify == true:
// fetch the repository // fetch the repository
Log.warning("sync-local: Not update ==> the repository is modified (pass through)") debug.warning("sync-local: Not update ==> the repository is modified (pass through)")
count_error += 1 count_error += 1
continue continue
Log.verbose("Check tracking and local branch:") debug.verbose("Check tracking and local branch:")
// get tracking branch // get tracking branch
ret_track = commands.get_current_tracking_branch(git_repo_path) ret_track = commands.get_current_tracking_branch(git_repo_path)
select_branch = commands.get_current_branch(git_repo_path) select_branch = commands.get_current_branch(git_repo_path)
Log.debug("sync-local: check: " + select_branch + " ==> " + ret_track) debug.debug("sync-local: check: " + select_branch + " ==> " + ret_track)
Log.verbose("Check forward:") debug.verbose("Check forward:")
is_forward = commands.is_forward(git_repo_path, ret_track) is_forward = commands.is_forward(git_repo_path, ret_track)
if is_forward == true: if is_forward == true:
// fetch the repository // fetch the repository
Log.warning("sync-local: Not update ==> the repository is forward the remote branch " + str(commands.get_forward(git_repo_path, ret_track))) debug.warning("sync-local: Not update ==> the repository is forward the remote branch " + str(commands.get_forward(git_repo_path, ret_track)))
count_error += 1 count_error += 1
continue continue
Log.verbose("Check behind:") debug.verbose("Check behind:")
is_behind = commands.is_behind(git_repo_path, ret_track) is_behind = commands.is_behind(git_repo_path, ret_track)
if is_behind == false: if is_behind == false:
// fetch the repository // fetch the repository
Log.info("sync-local: Nothing to do.") debug.info("sync-local: Nothing to do.")
continue continue
if reset_instead_of_rebase == true: if reset_instead_of_rebase == true:
Log.info("sync-local: Reset to " + ret_track) debug.info("sync-local: Reset to " + ret_track)
commands.reset_hard(git_repo_path, ret_track) commands.reset_hard(git_repo_path, ret_track)
else: else:
Log.info("sync-local: Reset to " + ret_track) debug.info("sync-local: Reset to " + ret_track)
commands.rebase(git_repo_path, ret_track) commands.rebase(git_repo_path, ret_track)
if count_error != 0: if count_error != 0:
Log.info(" ***********************************************************") debug.info(" ***********************************************************")
Log.info(" ** local sync partial warning on " + str(count_error) + " repository") debug.info(" ** local sync partial warning on " + str(count_error) + " repository")
Log.info(" ***********************************************************") debug.info(" ***********************************************************")
return env.ret_action_partial_done return env.ret_action_partial_done
//# Update the links: //# Update the links:

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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 config
@ -52,11 +52,11 @@ public void add_specific_arguments(my_args, section):
public void execute(_arguments): public void execute(_arguments):
just_download = false just_download = false
for elem in _arguments: for elem in _arguments:
if elem.getOptionName() == "download": if elem.get_option_name() == "download":
just_download = true just_download = true
Log.info("find remote name: '" + elem.getArg() + "'") debug.info("find remote name: '" + elem.get_arg() + "'")
else: else:
Log.error("SYNC Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") debug.error("SYNC Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()
@ -65,7 +65,7 @@ public void execute(_arguments):
// TODO: Load Old manifect to check diff ... // TODO: Load Old manifect to check diff ...
Log.info("update manifest : '" + str(env.get_island_path_manifest()) + "'") debug.info("update manifest : '" + str(env.get_island_path_manifest()) + "'")
is_modify_manifest = commands.check_repository_is_modify(env.get_island_path_manifest()) is_modify_manifest = commands.check_repository_is_modify(env.get_island_path_manifest())
if is_modify_manifest == true: if is_modify_manifest == true:
commands.fetch(env.get_island_path_manifest(), "origin") commands.fetch(env.get_island_path_manifest(), "origin")
@ -74,22 +74,22 @@ public void execute(_arguments):
file_source_manifest = new Path(env.get_island_path_manifest(), configuration.get_manifest_name()) file_source_manifest = new Path(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:
Log.error("Missing manifest file : '" + str(file_source_manifest) + "'") debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
mani = manifest.Manifest(file_source_manifest) mani = manifest.Manifest(file_source_manifest)
all_project = mani.get_all_configs() all_project = mani.get_all_configs()
Log.info("synchronize : " + str(len(all_project)) + " projects") debug.info("synchronize : " + str(len(all_project)) + " projects")
id_element = 0 id_element = 0
for elem in all_project: for elem in all_project:
id_element += 1 id_element += 1
base_display = tools.get_list_base_display(id_element, len(all_project), elem) base_display = tools.get_list_base_display(id_element, len(all_project), elem)
Log.info("sync : " + base_display) debug.info("sync : " + base_display)
tools.wait_for_server_if_needed() tools.wait_for_server_if_needed()
//Log.debug("elem : " + str(elem)) //debug.debug("elem : " + str(elem))
git_repo_path = new Path(env.get_island_root_path(), elem.path) git_repo_path = new Path(env.get_island_root_path(), elem.path)
if elem.tag != None: if elem.tag != None:
Log.warning("Need to select a specific tag version ... " + elem.tag) debug.warning("Need to select a specific tag version ... " + elem.tag)
if os.path.exists(git_repo_path) == false: if os.path.exists(git_repo_path) == false:
// this is a new clone ==> this is easy ... // this is a new clone ==> this is easy ...
//clone the manifest repository //clone the manifest repository
@ -102,17 +102,17 @@ public void execute(_arguments):
else: else:
address_manifest += "/" address_manifest += "/"
address_manifest += elem.name address_manifest += elem.name
Log.info("clone the repo") debug.info("clone the repo")
ret = commands.clone(git_repo_path, address_manifest, branch_name=elem.branch, origin=elem.select_remote["name"]) ret = commands.clone(git_repo_path, address_manifest, branch_name=elem.branch, origin=elem.select_remote["name"])
if ret[0] != "" \ if ret[0] != "" \
and ret[0] != false: and ret[0] != false:
// all is good, ready to get the system work corectly // all is good, ready to get the system work corectly
Log.info("'" + str(ret) + "'") debug.info("'" + str(ret) + "'")
Log.error("Clone repository does not work ... ") debug.error("Clone repository does not work ... ")
continue continue
// add global mirror list // add global mirror list
for mirror in elem.select_remote["mirror"]: for mirror in elem.select_remote["mirror"]:
Log.verbose("Add global mirror: " + str(mirror)) debug.verbose("Add global mirror: " + str(mirror))
cmd = "git remote add " + mirror["name"] + " " + mirror["fetch"] cmd = "git remote add " + mirror["name"] + " " + mirror["fetch"]
if mirror["fetch"][0:4] == "git@": if mirror["fetch"][0:4] == "git@":
cmd += ":" cmd += ":"
@ -123,46 +123,46 @@ public void execute(_arguments):
if ret != "" \ if ret != "" \
and ret != false: and ret != false:
// all is good, ready to get the system work corectly // all is good, ready to get the system work corectly
Log.info("'" + str(ret) + "'") debug.info("'" + str(ret) + "'")
Log.warning("Can not add global mirror ... ") debug.warning("Can not add global mirror ... ")
continue continue
Log.verbose("Add global mirror: " + str(mirror) + " (done)") debug.verbose("Add global mirror: " + str(mirror) + " (done)")
//Log.info("plop " + str(elem.select_remote.keys())) //debug.info("plop " + str(elem.select_remote.keys()))
// check submodule if requested: // check submodule if requested:
if elem.select_remote["sync"] == true \ if elem.select_remote["sync"] == true \
and os.path.exists(new Path(git_repo_path, ".gitmodules")) == true: and os.path.exists(new Path(git_repo_path, ".gitmodules")) == true:
Log.info(" ==> update submodule") debug.info(" ==> update submodule")
cmd = "git submodule init" cmd = "git submodule init"
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:
// all is good, ready to get the system work corectly // all is good, ready to get the system work corectly
Log.info("'" + str(ret) + "'") debug.info("'" + str(ret) + "'")
Log.error("Can not init submodules ... ") debug.error("Can not init submodules ... ")
continue continue
cmd = "git submodule update" cmd = "git submodule update"
ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path) ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path)
if ret[:16] == "Submodule path '": if ret[:16] == "Submodule path '":
//all is good ... //all is good ...
Log.info(" " + ret) debug.info(" " + ret)
} else if ret != "" \ elif ret != "" \
and ret != false: and ret != false:
// all is good, ready to get the system work corectly // all is good, ready to get the system work corectly
Log.info("'" + str(ret) + "'") debug.info("'" + str(ret) + "'")
Log.error("Can not init submodules ... ") debug.error("Can not init submodules ... ")
continue continue
continue continue
if just_download == true: if just_download == true:
Log.info("SYNC: Already downloaded") debug.info("SYNC: Already downloaded")
continue continue
if os.path.exists(new Path(git_repo_path,".git")) == false: if os.path.exists(new Path(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
Log.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")
// simply update the repository ... // simply update the repository ...
Log.verbose("Fetching project: ") debug.verbose("Fetching project: ")
// get tracking branch // get tracking branch
ret_track = commands.get_current_tracking_branch(git_repo_path) ret_track = commands.get_current_tracking_branch(git_repo_path)
@ -172,15 +172,15 @@ public void execute(_arguments):
if is_modify == true: if is_modify == true:
// fetch the repository // fetch the repository
commands.fetch(git_repo_path, elem.select_remote["name"]) commands.fetch(git_repo_path, elem.select_remote["name"])
Log.warning("[" + elem.name + "] Not update ==> the repository is modified (just fetch)") debug.warning("[" + elem.name + "] Not update ==> the repository is modified (just fetch)")
continue continue
commands.pull(git_repo_path, elem.select_remote["name"]) commands.pull(git_repo_path, elem.select_remote["name"])
Log.verbose("select branch = '" + select_branch + "' track: '" + str(ret_track) + "'") debug.verbose("select branch = '" + select_branch + "' track: '" + str(ret_track) + "'")
// check submodule if requested: // check submodule if requested:
if elem.select_remote["sync"] == true \ if elem.select_remote["sync"] == true \
and os.path.exists(new Path(git_repo_path, ".gitmodules")) == true: and os.path.exists(new Path(git_repo_path, ".gitmodules")) == true:
Log.info(" ==> sync submodule") debug.info(" ==> sync submodule")
commands.submodule_sync(git_repo_path) commands.submodule_sync(git_repo_path)
//# Update the links: //# Update the links:

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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 config
@ -53,23 +53,23 @@ public void help_example():
//# //#
public void execute(_arguments): public void execute(_arguments):
if len(_arguments) == 0: if len(_arguments) == 0:
Log.error("Missing argument to execute the current action [git repository] [path]") debug.error("Missing argument to execute the current action [git repository] [path]")
// the configuration availlable: // the configuration availlable:
path = "" path = ""
address_git = "" address_git = ""
for elem in _arguments: for elem in _arguments:
if elem.getOptionName() == "git repository": if elem.get_option_name() == "git repository":
address_git = elem.getArg() address_git = elem.get_arg()
} else if elem.getOptionName() == "path": elif elem.get_option_name() == "path":
path = elem.getArg() path = elem.get_arg()
else: else:
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
if address_git == "": if address_git == "":
Log.error("volatile-add: Missing git repository address", env.ret_action_wrong_parameters) debug.error("volatile-add: Missing git repository address", env.ret_action_wrong_parameters)
Log.info("Add 'volatile' repository: '" + address_git + "' path='" + path + "'") debug.info("Add 'volatile' repository: '" + address_git + "' path='" + path + "'")
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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 config
@ -37,16 +37,16 @@ public void help():
//# //#
public void execute(_arguments): public void execute(_arguments):
for elem in _arguments: for elem in _arguments:
Log.error("Wrong argument: '" + elem.getOptionName() + "' '" + elem.getArg() + "'") debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
// check system is OK // check system is OK
manifest.check_lutin_is_init() manifest.check_lutin_is_init()
conf = config.get_unique_config() conf = config.get_unique_config()
volatiles = conf.get_volatile() volatiles = conf.get_volatile()
Log.info("List of all volatiles repository: ") debug.info("List of all volatiles repository: ")
for elem in volatiles: for elem in volatiles:
Log.info("\t" + elem["path"] + "\r\t\t\t\t" + elem["git_address"]) debug.info("\t" + elem["path"] + "\r\t\t\t\t" + elem["git_address"])
return None return None

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log 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 config
@ -28,22 +28,22 @@ public void display_status(elem, argument_remote_name, argument_display_tag, id_
volatile = "" volatile = ""
if elem.volatile == true: if elem.volatile == true:
volatile = " (volatile)" volatile = " (volatile)"
Log.verbose("status : " + base_display) debug.verbose("status : " + base_display)
//Log.debug("elem : " + str(elem)) //debug.debug("elem : " + str(elem))
git_repo_path = new Path(env.get_island_root_path(), elem.path) git_repo_path = new Path(env.get_island_root_path(), elem.path)
if os.path.exists(git_repo_path) == false: if os.path.exists(git_repo_path) == false:
Log.info(base_display + volatile + "\r\t\t\t\t\t\t\t\t\t" + " (not download)") debug.info(base_display + volatile + "\r\t\t\t\t\t\t\t\t\t" + " (not download)")
return return
is_modify = commands.check_repository_is_modify(git_repo_path) is_modify = commands.check_repository_is_modify(git_repo_path)
list_branch = commands.get_list_branch_all(git_repo_path) list_branch = commands.get_list_branch_all(git_repo_path)
select_branch = commands.get_current_branch(git_repo_path) select_branch = commands.get_current_branch(git_repo_path)
Log.verbose("List all branch: " + str(list_branch)) debug.verbose("List all branch: " + str(list_branch))
if select_branch[:len(base_name_of_a_tagged_branch)] != base_name_of_a_tagged_branch: if select_branch[:len(base_name_of_a_tagged_branch)] != base_name_of_a_tagged_branch:
// get tracking branch // get tracking branch
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, select_branch) tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, select_branch)
if tracking_remote_branch == None: if tracking_remote_branch == None:
Log.info(base_display + volatile + "\r\t\t\t\t\t\t\t (NO BRANCH)") debug.info(base_display + volatile + "\r\t\t\t\t\t\t\t (NO BRANCH)")
return return
else: else:
tracking_remote_branch = select_branch[len(base_name_of_a_tagged_branch):] tracking_remote_branch = select_branch[len(base_name_of_a_tagged_branch):]
@ -51,7 +51,7 @@ public void display_status(elem, argument_remote_name, argument_display_tag, id_
if is_modify == true: if is_modify == true:
modify_status = " *** " modify_status = " *** "
Log.verbose("select branch = '" + select_branch + "' is modify : " + str(is_modify) + " track: '" + str(tracking_remote_branch) + "'") debug.verbose("select branch = '" + select_branch + "' is modify : " + str(is_modify) + " track: '" + str(tracking_remote_branch) + "'")
ret_current_branch_sha1 = commands.get_revision_list_to_branch(git_repo_path, select_branch) ret_current_branch_sha1 = commands.get_revision_list_to_branch(git_repo_path, select_branch)
ret_track_branch_sha1 = commands.get_revision_list_to_branch(git_repo_path, tracking_remote_branch) ret_track_branch_sha1 = commands.get_revision_list_to_branch(git_repo_path, tracking_remote_branch)
@ -80,7 +80,7 @@ public void display_status(elem, argument_remote_name, argument_display_tag, id_
// check the current tags of the repository // check the current tags of the repository
if argument_display_tag == true: if argument_display_tag == true:
ret_current_tags = commands.get_tags_current(git_repo_path) ret_current_tags = commands.get_tags_current(git_repo_path)
Log.verbose("tags found: " + str(ret_current_tags)) debug.verbose("tags found: " + str(ret_current_tags))
for elem_tag in ret_current_tags: for elem_tag in ret_current_tags:
if len(tags_comment) != 0: if len(tags_comment) != 0:
tags_comment += "," tags_comment += ","
@ -89,46 +89,46 @@ public void display_status(elem, argument_remote_name, argument_display_tag, id_
tags_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[" + tags_comment + "]" tags_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[" + tags_comment + "]"
else: else:
tags_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t- - - - -" tags_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t- - - - -"
Log.info(base_display + volatile + "\r\t\t\t\t\t\t\t" + modify_status + "(" + select_branch + " -> " + tracking_remote_branch + ")" + behind_forward_comment + tags_comment) debug.info(base_display + volatile + "\r\t\t\t\t\t\t\t" + modify_status + "(" + select_branch + " -> " + tracking_remote_branch + ")" + behind_forward_comment + tags_comment)
if is_modify == true: if is_modify == true:
cmd = "git status --short" cmd = "git status --short"
Log.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)
tmp_color_red = "\033[31m" tmp_color_red = "\033[31m"
tmp_color_default= "\033[00m" tmp_color_default= "\033[00m"
Log.info(tmp_color_red + ret_diff[1] + tmp_color_default) debug.info(tmp_color_red + ret_diff[1] + tmp_color_default)
return in_behind return in_behind
public void deliver_check(elem, argument_remote_name, id_element, base_display, source_branch, destination_branch): public void deliver_check(elem, argument_remote_name, id_element, base_display, source_branch, destination_branch):
deliver_availlable = true deliver_availlable = true
Log.debug("deliver-ckeck: " + base_display) debug.debug("deliver-ckeck: " + base_display)
Log.debug(" ==> check repo exist") debug.debug(" ==> check repo exist")
// Check the repo exist // Check the repo exist
git_repo_path = new Path(env.get_island_root_path(), elem.path) git_repo_path = new Path(env.get_island_root_path(), elem.path)
if os.path.exists(git_repo_path) == false: if os.path.exists(git_repo_path) == false:
Log.warning("deliver-ckeck: " + base_display + " ==> MUST be download") debug.warning("deliver-ckeck: " + base_display + " ==> MUST be download")
return false return false
Log.debug(" ==> check is modify") debug.debug(" ==> check is modify")
// check if the curent repo is modify // check if the curent repo is modify
is_modify = commands.check_repository_is_modify(git_repo_path) is_modify = commands.check_repository_is_modify(git_repo_path)
if is_modify == true: if is_modify == true:
Log.warning("deliver-ckeck: " + base_display + " ==> MUST not be modify") debug.warning("deliver-ckeck: " + base_display + " ==> MUST not be modify")
return false return false
Log.debug(" ==> check current branch is '" + source_branch + "'") debug.debug(" ==> check current branch is '" + source_branch + "'")
// check if we are on source_branch // check if we are on source_branch
select_branch = commands.get_current_branch(git_repo_path) select_branch = commands.get_current_branch(git_repo_path)
if select_branch != source_branch: if select_branch != source_branch:
Log.warning("deliver-ckeck: " + base_display + " ==> MUST be on source branch: '" + source_branch + "' and is: '" + select_branch + "'") debug.warning("deliver-ckeck: " + base_display + " ==> MUST be on source branch: '" + source_branch + "' and is: '" + select_branch + "'")
return false return false
Log.debug(" ==> check have tracking branch") debug.debug(" ==> check have tracking branch")
// check if we have a remote traking branch // check if we have a remote traking branch
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, select_branch) tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, select_branch)
if tracking_remote_branch == None: if tracking_remote_branch == None:
Log.warning("deliver-ckeck: " + base_display + " ==> MUST have a remote tracking branch") debug.warning("deliver-ckeck: " + base_display + " ==> MUST have a remote tracking branch")
deliver_availlable = false deliver_availlable = false
@ -136,17 +136,17 @@ public void deliver_check(elem, argument_remote_name, id_element, base_display,
commands.checkout(git_repo_path, destination_branch) commands.checkout(git_repo_path, destination_branch)
// TODO: check return value // TODO: check return value
Log.debug(" ==> check current branch is '" + source_branch + "'") debug.debug(" ==> check current branch is '" + source_branch + "'")
// check if we are on "master" // check if we are on "master"
select_branch = commands.get_current_branch(git_repo_path) select_branch = commands.get_current_branch(git_repo_path)
if select_branch != destination_branch: if select_branch != destination_branch:
Log.warning("deliver-ckeck: " + base_display + " ==> Can not checkout branch: '" + destination_branch + "' and is: '" + select_branch + "'") debug.warning("deliver-ckeck: " + base_display + " ==> Can not checkout branch: '" + destination_branch + "' and is: '" + select_branch + "'")
deliver_availlable = false deliver_availlable = false
Log.debug(" ==> check have tracking branch") debug.debug(" ==> check have tracking branch")
// check if we have a remote traking branch // check if we have a remote traking branch
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, select_branch) tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, select_branch)
if tracking_remote_branch == None: if tracking_remote_branch == None:
Log.warning("deliver-ckeck: " + base_display + " ==> MUST have a remote tracking branch") debug.warning("deliver-ckeck: " + base_display + " ==> MUST have a remote tracking branch")
deliver_availlable = false deliver_availlable = false
@ -155,7 +155,7 @@ public void deliver_check(elem, argument_remote_name, id_element, base_display,
// check if we have a local branch // check if we have a local branch
list_branch_local = commands.get_list_branch_local(git_repo_path) list_branch_local = commands.get_list_branch_local(git_repo_path)
if destination_branch not in list_branch_local: if destination_branch not in list_branch_local:
Log.warning("deliver-ckeck: " + base_display + " ==> MUST have local branch named '" + destination_branch + "'") debug.warning("deliver-ckeck: " + base_display + " ==> MUST have local branch named '" + destination_branch + "'")
deliver_availlable = false deliver_availlable = false
// TODO: check source_branch is up to date // TODO: check source_branch is up to date
@ -170,16 +170,16 @@ public void deliver_check(elem, argument_remote_name, id_element, base_display,
public void checkout_elem(elem, argument_remote_name, branch_to_checkout, base_display): public void checkout_elem(elem, argument_remote_name, branch_to_checkout, base_display):
Log.verbose("checkout : " + base_display) debug.verbose("checkout : " + base_display)
git_repo_path = new Path(env.get_island_root_path(), elem.path) git_repo_path = new Path(env.get_island_root_path(), elem.path)
if os.path.exists(git_repo_path) == false: if os.path.exists(git_repo_path) == false:
Log.warning("checkout " + base_display + " ==> repository does not exist ...") debug.warning("checkout " + base_display + " ==> repository does not exist ...")
return false return false
// check if the repository is modify // check if the repository is modify
is_modify = commands.check_repository_is_modify(git_repo_path) is_modify = commands.check_repository_is_modify(git_repo_path)
if is_modify == true: if is_modify == true:
Log.warning("checkout " + base_display + " ==> modify data can not checkout new branch") debug.warning("checkout " + base_display + " ==> modify data can not checkout new branch")
return false return false
list_branch_local = commands.get_list_branch_local(git_repo_path) list_branch_local = commands.get_list_branch_local(git_repo_path)
@ -190,29 +190,29 @@ public void checkout_elem(elem, argument_remote_name, branch_to_checkout, base_d
branch_to_checkout = base_name_of_a_tagged_branch + str(elem.tag) branch_to_checkout = base_name_of_a_tagged_branch + str(elem.tag)
is_tag = true is_tag = true
if elem.volatile == true: if elem.volatile == true:
Log.info("checkout " + base_display + " ==> Can not checkout for 'volatile' repository") debug.info("checkout " + base_display + " ==> Can not checkout for 'volatile' repository")
return true return true
if elem.tag == None: if elem.tag == None:
Log.info("checkout " + base_display + " ==> Can not checkout for '''None''' Tag") debug.info("checkout " + base_display + " ==> Can not checkout for '''None''' Tag")
return true return true
// check if we are on the good branch: // check if we are on the good branch:
if branch_to_checkout == select_branch: if branch_to_checkout == select_branch:
Log.info("checkout " + base_display + " ==> No change already on good branch") debug.info("checkout " + base_display + " ==> No change already on good branch")
return true return true
// check if we have already checkout the branch before // check if we have already checkout the branch before
Log.verbose(" check : " + branch_to_checkout + " in " + str(list_branch_local)) debug.verbose(" check : " + branch_to_checkout + " in " + str(list_branch_local))
if branch_to_checkout in list_branch_local: if branch_to_checkout in list_branch_local:
cmd = "git checkout " + branch_to_checkout cmd = "git checkout " + branch_to_checkout
Log.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[0] != 0 \ if ret[0] != 0 \
and ret[1] != "" \ and ret[1] != "" \
and ret != false: and ret != false:
Log.info("'" + str(ret) + "'") debug.info("'" + str(ret) + "'")
Log.error("checkout " + base_display + " ==> Can not checkout to the correct branch") debug.error("checkout " + base_display + " ==> Can not checkout to the correct branch")
return false return false
Log.info("checkout " + base_display + " ==> switch branch") debug.info("checkout " + base_display + " ==> switch branch")
// TODO : Check the number of commit to the origin/XXX branch .... // TODO : Check the number of commit to the origin/XXX branch ....
return true return true
@ -227,39 +227,39 @@ public void checkout_elem(elem, argument_remote_name, branch_to_checkout, base_d
if is_tag == false: if is_tag == false:
list_branch_remote = commands.get_list_branch_remote(git_repo_path) list_branch_remote = commands.get_list_branch_remote(git_repo_path)
if elem.select_remote["name"] + "/" + branch_to_checkout in list_branch_remote: if elem.select_remote["name"] + "/" + branch_to_checkout in list_branch_remote:
Log.info(" ==> find ...") debug.info(" ==> find ...")
else: else:
Log.info("checkout " + base_display + " ==> NO remote branch") debug.info("checkout " + base_display + " ==> NO remote branch")
return true return true
// 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
// + " --track " + elem.select_remote["name"] + "/" + branch_to_checkout // + " --track " + elem.select_remote["name"] + "/" + branch_to_checkout
Log.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[1] != "" \
and ret != false: and ret != false:
Log.info("'" + str(ret) + "'") debug.info("'" + str(ret) + "'")
Log.error("checkout " + base_display + " ==> Can not checkout to the correct branch") debug.error("checkout " + base_display + " ==> Can not checkout to the correct branch")
return false return false
Log.info("checkout " + base_display + " ==> create new branch") debug.info("checkout " + base_display + " ==> create new branch")
return true return true
// Checkout a specific tags: // Checkout a specific tags:
if elem.tag in list_tags: if elem.tag in list_tags:
Log.info(" ==> find ...") debug.info(" ==> find ...")
else: else:
Log.info("checkout " + base_display + " ==> NO remote tags") debug.info("checkout " + base_display + " ==> NO remote tags")
return true return true
// checkout the new branch: // checkout the new branch:
cmd = "git checkout --quiet " + elem.tag + " -b " + branch_to_checkout cmd = "git checkout --quiet " + elem.tag + " -b " + branch_to_checkout
// + " --track " + elem.select_remote["name"] + "/" + branch_to_checkout // + " --track " + elem.select_remote["name"] + "/" + branch_to_checkout
Log.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[1] != "" \
and ret != false: and ret != false:
Log.info("'" + str(ret) + "'") debug.info("'" + str(ret) + "'")
Log.error("checkout " + base_display + " ==> Can not checkout to the correct tags") debug.error("checkout " + base_display + " ==> Can not checkout to the correct tags")
return false return false
Log.info("checkout " + base_display + " ==> create new branch: " + branch_to_checkout) debug.info("checkout " + base_display + " ==> create new branch: " + branch_to_checkout)
return true return true
@ -268,26 +268,26 @@ public void get_current_version_repo(git_repo_path):
add_in_version_management = false add_in_version_management = false
version_description = None version_description = None
if os.path.exists(version_path_file) == false: if os.path.exists(version_path_file) == false:
Log.info("deliver: ==> No 'version.txt' file ==> not manage release version....") debug.info("deliver: ==> No 'version.txt' file ==> not manage release version....")
// Action to do: // Action to do:
valid = false valid = false
while valid == false: while valid == false:
Log.info("Create a new version: (0.0.0)") debug.info("Create a new version: (0.0.0)")
Log.info(" (1) Add in managing version") debug.info(" (1) Add in managing version")
Log.info(" (2) Do NOTHING & continue") debug.info(" (2) Do NOTHING & continue")
input1 = input() input1 = input()
if input1 in ["1", "2"]: if input1 in ["1", "2"]:
valid = true valid = true
else: else:
Log.info("!!! Must select in range " + str(["1", "2"])) debug.info("!!! Must select in range " + str(["1", "2"]))
if input1 == "1": if input1 == "1":
version_description = [0, 0, 0] version_description = [0, 0, 0]
add_in_version_management = true add_in_version_management = true
} else if input1 == "2": elif input1 == "2":
Log.info("Continue Not managing for this repository") debug.info("Continue Not managing for this repository")
return (None, None) return (None, None)
else: else:
Log.warning("An error occured for this repository") debug.warning("An error occured for this repository")
return (None, None) return (None, None)
else: else:
version_description = tools.version_string_to_list(tools.file_read_data(version_path_file)) version_description = tools.version_string_to_list(tools.file_read_data(version_path_file))
@ -304,10 +304,10 @@ public void create_new_version_repo(git_repo_path, version_description, add_in_v
for elem_sha1 in ret_destination_branch_sha1: for elem_sha1 in ret_destination_branch_sha1:
if elem_sha1 not in ret_source_branch_sha1: if elem_sha1 not in ret_source_branch_sha1:
message = commands.get_specific_commit_message(git_repo_path, elem_sha1) message = commands.get_specific_commit_message(git_repo_path, elem_sha1)
Log.warning("deliver: Forward commit: '" + message + "'") debug.warning("deliver: Forward commit: '" + message + "'")
have_forward = true have_forward = true
if have_forward == true: if have_forward == true:
Log.error("'" + destination_branch + "' branch must not be forward '" + source_branch + "' branch") debug.error("'" + destination_branch + "' branch must not be forward '" + source_branch + "' branch")
return None return None
behind_message = "" behind_message = ""
behind_count = 0 behind_count = 0
@ -317,30 +317,30 @@ public void create_new_version_repo(git_repo_path, version_description, add_in_v
behind_count += 1 behind_count += 1
behind_message = message behind_message = message
if behind_count == 0 and add_in_version_management == false: if behind_count == 0 and add_in_version_management == false:
Log.info("deliver: ==> Nothing to do (1).") debug.info("deliver: ==> Nothing to do (1).")
return None return None
if behind_count == 1 \ if behind_count == 1 \
and ( behind_message == default_behind_message and ( behind_message == default_behind_message
or behind_message == default_update_message): or behind_message == default_update_message):
Log.info("deliver: ==> Nothing to do (2).") debug.info("deliver: ==> Nothing to do (2).")
return None return None
for elem_sha1 in ret_source_branch_sha1: for elem_sha1 in ret_source_branch_sha1:
if elem_sha1 not in ret_destination_branch_sha1: if elem_sha1 not in ret_destination_branch_sha1:
message = commands.get_specific_commit_message(git_repo_path, elem_sha1) message = commands.get_specific_commit_message(git_repo_path, elem_sha1)
Log.info("deliver: Behind commit: '" + message + "'") debug.info("deliver: Behind commit: '" + message + "'")
// Choice of the new version: // Choice of the new version:
valid = false valid = false
while valid == false: while valid == false:
Log.info("update version: curent: " + str(version_description)) debug.info("update version: curent: " + str(version_description))
Log.info(" (1) Major version (change API)") debug.info(" (1) Major version (change API)")
Log.info(" (2) Medium version (add feature)") debug.info(" (2) Medium version (add feature)")
Log.info(" (3) Minor version (Bug fix & doc)") debug.info(" (3) Minor version (Bug fix & doc)")
Log.info(" (4) Do not release & continue") debug.info(" (4) Do not release & continue")
input1 = input() input1 = input()
if input1 in ["1", "2", "3", "4"]: if input1 in ["1", "2", "3", "4"]:
valid = true valid = true
else: else:
Log.info("!!! Must select in range " + str(["1", "2", "3", "4"])) debug.info("!!! Must select in range " + str(["1", "2", "3", "4"]))
// limit and force at 3 the nuber of variables // limit and force at 3 the nuber of variables
version_description_tmp = version_description version_description_tmp = version_description
version_description = [] version_description = []
@ -356,24 +356,24 @@ public void create_new_version_repo(git_repo_path, version_description, add_in_v
version_description.append(version_description_tmp[2]) version_description.append(version_description_tmp[2])
else: else:
version_description.append(0) version_description.append(0)
Log.info("update version: curent: " + str(version_description)) debug.info("update version: curent: " + str(version_description))
// increment the version // increment the version
if input1 == "1": if input1 == "1":
version_description[0] += 1 version_description[0] += 1
version_description[1] = 0 version_description[1] = 0
version_description[2] = 0 version_description[2] = 0
} else if input1 == "2": elif input1 == "2":
version_description[1] += 1 version_description[1] += 1
version_description[2] = 0 version_description[2] = 0
} else if input1 == "3": elif input1 == "3":
version_description[2] += 1 version_description[2] += 1
} else if input1 == "4": elif input1 == "4":
Log.info("No release for this repository") debug.info("No release for this repository")
return None return None
else: else:
Log.warning("An error occured for this repository") debug.warning("An error occured for this repository")
return None return None
Log.info("update version: curent: " + str(version_description)) debug.info("update version: curent: " + str(version_description))
return version_description return version_description
@ -381,59 +381,59 @@ public void deliver_push(elem, argument_remote_name, destination_branch, source_
// Check the repo exist // Check the repo exist
git_repo_path = new Path(env.get_island_root_path(), elem.path) git_repo_path = new Path(env.get_island_root_path(), elem.path)
if os.path.exists(git_repo_path) == false: if os.path.exists(git_repo_path) == false:
Log.warning("deliver-push: " + base_display + " ==> MUST be download") debug.warning("deliver-push: " + base_display + " ==> MUST be download")
return return
// check if we are on destination_branch // check if we are on destination_branch
select_branch = commands.get_current_branch(git_repo_path) select_branch = commands.get_current_branch(git_repo_path)
if select_branch != destination_branch: if select_branch != destination_branch:
Log.warning("deliver-push: " + base_display + " ==> MUST be on '" + destination_branch + "'") debug.warning("deliver-push: " + base_display + " ==> MUST be on '" + destination_branch + "'")
return return
// check if we have a local branch // check if we have a local branch
list_branch_local = commands.get_list_branch_local(git_repo_path) list_branch_local = commands.get_list_branch_local(git_repo_path)
if source_branch not in list_branch_local: if source_branch not in list_branch_local:
Log.warning("deliver-push: " + base_display + " ==> No '" + source_branch + "' (not managed)") debug.warning("deliver-push: " + base_display + " ==> No '" + source_branch + "' (not managed)")
return return
if destination_branch not in list_branch_local: if destination_branch not in list_branch_local:
Log.warning("deliver-push: " + base_display + " ==> No '" + destination_branch + "' (not managed)") debug.warning("deliver-push: " + base_display + " ==> No '" + destination_branch + "' (not managed)")
return return
list_of_element_to_push = [] list_of_element_to_push = []
// check sha1 of destination_branch // check sha1 of destination_branch
sha_1_destination = commands.get_sha1_for_branch(git_repo_path, destination_branch) sha_1_destination = commands.get_sha1_for_branch(git_repo_path, destination_branch)
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, destination_branch) tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, destination_branch)
if tracking_remote_branch == None: if tracking_remote_branch == None:
Log.warning("deliver-push: " + base_display + " ==> '" + destination_branch + "' have no tracking branch") debug.warning("deliver-push: " + base_display + " ==> '" + destination_branch + "' have no tracking branch")
deliver_availlable = false deliver_availlable = false
sha_1_destination_tracking = commands.get_sha1_for_branch(git_repo_path, tracking_remote_branch) sha_1_destination_tracking = commands.get_sha1_for_branch(git_repo_path, tracking_remote_branch)
if sha_1_destination == sha_1_destination_tracking: if sha_1_destination == sha_1_destination_tracking:
Log.info("deliver-push: " + base_display + " ==> '" + destination_branch + "' && '" + tracking_remote_branch + "' have the same sha1") debug.info("deliver-push: " + base_display + " ==> '" + destination_branch + "' && '" + tracking_remote_branch + "' have the same sha1")
else: else:
list_of_element_to_push.append(destination_branch) list_of_element_to_push.append(destination_branch)
// check sha1 of source_branch // check sha1 of source_branch
sha_1_source = commands.get_sha1_for_branch(git_repo_path, source_branch) sha_1_source = commands.get_sha1_for_branch(git_repo_path, source_branch)
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, source_branch) tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, source_branch)
if tracking_remote_branch == None: if tracking_remote_branch == None:
Log.info("deliver-push: " + base_display + " ==> '" + source_branch + "' have no tracking branch") debug.info("deliver-push: " + base_display + " ==> '" + source_branch + "' have no tracking branch")
deliver_availlable = false deliver_availlable = false
sha_1_source_tracking = commands.get_sha1_for_branch(git_repo_path, tracking_remote_branch) sha_1_source_tracking = commands.get_sha1_for_branch(git_repo_path, tracking_remote_branch)
if sha_1_source == sha_1_source_tracking: if sha_1_source == sha_1_source_tracking:
Log.info("deliver-push: " + base_display + " ==> '" + source_branch + "' && '" + tracking_remote_branch + "' have the same sha1") debug.info("deliver-push: " + base_display + " ==> '" + source_branch + "' && '" + tracking_remote_branch + "' have the same sha1")
else: else:
list_of_element_to_push.append(source_branch) list_of_element_to_push.append(source_branch)
ret_current_tags = commands.get_tags_current(git_repo_path) ret_current_tags = commands.get_tags_current(git_repo_path)
if len(ret_current_tags) == 0: if len(ret_current_tags) == 0:
Log.info("deliver-push: " + base_display + " ==> No tag on the current '" + destination_branch + "'") debug.info("deliver-push: " + base_display + " ==> No tag on the current '" + destination_branch + "'")
return return
if len(ret_current_tags) > 1: if len(ret_current_tags) > 1:
Log.info("deliver-push: " + base_display + " ==> Too mush tags on the current '" + destination_branch + "' : " + str(ret_current_tags) + " ==> only support 1") debug.info("deliver-push: " + base_display + " ==> Too mush tags on the current '" + destination_branch + "' : " + str(ret_current_tags) + " ==> only support 1")
return return
list_remote_tags = commands.get_tags_remote(git_repo_path, argument_remote_name) list_remote_tags = commands.get_tags_remote(git_repo_path, argument_remote_name)
Log.verbose("remote tags: " + str(list_remote_tags)) debug.verbose("remote tags: " + str(list_remote_tags))
if ret_current_tags[0] not in list_remote_tags: if ret_current_tags[0] not in list_remote_tags:
Log.info("deliver-push: " + base_display + " ==> tag already exist.") debug.info("deliver-push: " + base_display + " ==> tag already exist.")
list_of_element_to_push.append(ret_current_tags[0]) list_of_element_to_push.append(ret_current_tags[0])
if len(list_of_element_to_push) == 0: if len(list_of_element_to_push) == 0:
Log.info("deliver-push: " + base_display + " ==> Everything up-to-date") debug.info("deliver-push: " + base_display + " ==> Everything up-to-date")
return return
Log.info("deliver-push: " + base_display + " ==> element to push:" + str(list_of_element_to_push)) debug.info("deliver-push: " + base_display + " ==> element to push:" + str(list_of_element_to_push))
//push all on the server: //push all on the server:
commands.push(git_repo_path, argument_remote_name, list_of_element_to_push) commands.push(git_repo_path, argument_remote_name, list_of_element_to_push)

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log from realog import debug
from island import tools from island import tools
from island import env from island import env
import os import os
@ -18,23 +18,23 @@ public void update(configuration, mani, type_call):
// TODO: do not remove link when not needed // TODO: do not remove link when not needed
if len(configuration.get_links()) != 0 \ if len(configuration.get_links()) != 0 \
or len(mani.get_links()) != 0: or len(mani.get_links()) != 0:
Log.info(type_call + ": remove old links ...") debug.info(type_call + ": remove old links ...")
for elem in configuration.get_links(): for elem in configuration.get_links():
base_path = new Path(env.get_island_root_path(), elem["destination"]) base_path = new Path(env.get_island_root_path(), elem["destination"])
Log.info(type_call + ": link: " + str(base_path)) debug.info(type_call + ": link: " + str(base_path))
if os.path.islink(base_path) == true: if os.path.islink(base_path) == true:
os.unlink(base_path) os.unlink(base_path)
else: else:
Log.error(type_call + ": remove link is not authorised ==> not a link", crash=false) debug.error(type_call + ": remove link is not authorised ==> not a link", crash=false)
have_error = true have_error = true
configuration.clear_links() configuration.clear_links()
Log.info(type_call + ": add new links ...") debug.info(type_call + ": add new links ...")
for elem in mani.get_links(): for elem in mani.get_links():
base_path = new Path(env.get_island_root_path(), elem["destination"]) base_path = new Path(env.get_island_root_path(), elem["destination"])
source_path = new Path(env.get_island_root_path(), elem["source"]) source_path = new Path(env.get_island_root_path(), elem["source"])
Log.info(type_call + ": link: " + str(base_path)) debug.info(type_call + ": link: " + str(base_path))
if os.path.exists(base_path) == true: if os.path.exists(base_path) == true:
Log.error(type_call + ": create link is not possible ==> path already exist", crash=false) debug.error(type_call + ": create link is not possible ==> path already exist", crash=false)
have_error = true have_error = true
else: else:
tools.create_directory_of_file(base_path) tools.create_directory_of_file(base_path)

View File

@ -14,10 +14,10 @@ import errno
import fnmatch import fnmatch
import stat import stat
// Local import // Local import
from realog import Log from realog import debug
from . import env from . import env
from . import multiprocess from . import multiprocess
from . import Log from . import debug
@ -29,7 +29,7 @@ from . import Log
public void check_repository_is_modify(path_repository): public void check_repository_is_modify(path_repository):
// check if the repository is modify // check if the repository is modify
cmd = "git diff --quiet" cmd = "git diff --quiet"
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "check_repository_is_modify", error_only=true, availlable_return=[0,1], display_if_nothing=false) multiprocess.generic_display_error(return_value, "check_repository_is_modify", error_only=true, availlable_return=[0,1], display_if_nothing=false)
ret_diff = return_value ret_diff = return_value
@ -40,7 +40,7 @@ public void check_repository_is_modify(path_repository):
public void get_list_branch_meta(path_repository): public void get_list_branch_meta(path_repository):
// get local branch // get local branch
cmd = "git branch -a" cmd = "git branch -a"
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "get_list_branch_meta", error_only=true) multiprocess.generic_display_error(return_value, "get_list_branch_meta", error_only=true)
ret_branch = return_value ret_branch = return_value
@ -67,7 +67,7 @@ public void get_list_branch_meta(path_repository):
"name": branch_name, "name": branch_name,
"select": is_selected "select": is_selected
}) })
Log.extreme_verbose("List all branch Meta: " + str(out)) debug.extreme_verbose("List all branch Meta: " + str(out))
return out return out
@ -76,7 +76,7 @@ public void get_list_branch_all(path_repository):
out = [] out = []
for elem in tmp: for elem in tmp:
out.append(elem["name"]) out.append(elem["name"])
Log.verbose("List all branch: " + str(out)) debug.verbose("List all branch: " + str(out))
return out return out
public void get_list_branch_local(path_repository): public void get_list_branch_local(path_repository):
@ -85,7 +85,7 @@ public void get_list_branch_local(path_repository):
for elem in tmp: for elem in tmp:
if elem["remote"] == false: if elem["remote"] == false:
out.append(elem["name"]) out.append(elem["name"])
Log.verbose("List local branch: " + str(out)) debug.verbose("List local branch: " + str(out))
return out return out
public void get_list_branch_remote(path_repository): public void get_list_branch_remote(path_repository):
@ -94,32 +94,32 @@ public void get_list_branch_remote(path_repository):
for elem in tmp: for elem in tmp:
if elem["remote"] == true: if elem["remote"] == true:
out.append(elem["name"]) out.append(elem["name"])
Log.verbose("List remote branch: " + str(out)) debug.verbose("List remote branch: " + str(out))
return out return out
public void get_current_branch(path_repository): public void get_current_branch(path_repository):
tmp = get_list_branch_meta(path_repository) tmp = get_list_branch_meta(path_repository)
for elem in tmp: for elem in tmp:
if elem["select"] == true: if elem["select"] == true:
Log.verbose("List local branch: " + str(elem["name"])) debug.verbose("List local branch: " + str(elem["name"]))
return elem["name"] return elem["name"]
Log.verbose("List local branch: None" ) debug.verbose("List local branch: None" )
return None return None
public void get_current_tracking_branch(path_repository): public void get_current_tracking_branch(path_repository):
// get tracking branch // get tracking branch
cmd = "git rev-parse --abbrev-ref --symbolic-full-name @{u}" cmd = "git rev-parse --abbrev-ref --symbolic-full-name @{u}"
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
if return_value[1] == "@{u}": if return_value[1] == "@{u}":
Log.warning("in '" + path_repository + "' no tracking branch is specify") debug.warning("in '" + path_repository + "' no tracking branch is specify")
return None return None
multiprocess.generic_display_error(return_value, "get_current_tracking_branch", error_only=true) multiprocess.generic_display_error(return_value, "get_current_tracking_branch", error_only=true)
return return_value[1] return return_value[1]
public void get_revision_list_to_branch(path_repository, branch): public void get_revision_list_to_branch(path_repository, branch):
cmd = "git rev-list " + branch cmd = "git rev-list " + branch
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "get_revision_list_to_branch", error_only=true) multiprocess.generic_display_error(return_value, "get_revision_list_to_branch", error_only=true)
return return_value[1].split('\n') return return_value[1].split('\n')
@ -128,7 +128,7 @@ public void get_specific_commit_message(path_repository, sha_1):
if sha_1 == None or sha_1 == "": if sha_1 == None or sha_1 == "":
return "" return ""
cmd = "git log --format=%B -n 1 " + sha_1 cmd = "git log --format=%B -n 1 " + sha_1
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "get_specific_commit_message", error_only=true) multiprocess.generic_display_error(return_value, "get_specific_commit_message", error_only=true)
return return_value[1].split('\n')[0] return return_value[1].split('\n')[0]
@ -137,7 +137,7 @@ public void get_sha1_for_branch(path_repository, branch_name):
if branch_name == None or branch_name == "": if branch_name == None or branch_name == "":
return None return None
cmd = "git rev-parse " + branch_name cmd = "git rev-parse " + branch_name
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "get_sha1_for_branch", error_only=true) multiprocess.generic_display_error(return_value, "get_sha1_for_branch", error_only=true)
return return_value[1].split('\n')[0] return return_value[1].split('\n')[0]
@ -145,7 +145,7 @@ public void get_sha1_for_branch(path_repository, branch_name):
public void get_tags_current(path_repository): public void get_tags_current(path_repository):
cmd = "git tag --points-at" cmd = "git tag --points-at"
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "get_tags_current", error_only=true) multiprocess.generic_display_error(return_value, "get_tags_current", error_only=true)
list_tags = [] list_tags = []
@ -156,7 +156,7 @@ public void get_tags_current(path_repository):
public void get_tags(path_repository): public void get_tags(path_repository):
cmd = "git tag" cmd = "git tag"
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "get_tags", error_only=true) multiprocess.generic_display_error(return_value, "get_tags", error_only=true)
return return_value[1].split('\n') return return_value[1].split('\n')
@ -165,11 +165,11 @@ public void get_tags_remote(path_repository, remote_name):
if remote_name == "" or remote_name == None: if remote_name == "" or remote_name == None:
return get_current_tracking_branch(path_repository) return get_current_tracking_branch(path_repository)
cmd = "git ls-remote --tags " + remote_name cmd = "git ls-remote --tags " + remote_name
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "get_tags_remote", error_only=true) multiprocess.generic_display_error(return_value, "get_tags_remote", error_only=true)
list_element = return_value[1].split('\n') list_element = return_value[1].split('\n')
Log.verbose(" receive: " + str(list_element)) debug.verbose(" receive: " + str(list_element))
//6bc01117e85d00686ae2d423193a161e82df9a44 refs/tags/0.1.0 //6bc01117e85d00686ae2d423193a161e82df9a44 refs/tags/0.1.0
//7ef9caa51cf3744de0f46352e5aa07bd4980fe89 refs/tags/v0.2.0 //7ef9caa51cf3744de0f46352e5aa07bd4980fe89 refs/tags/v0.2.0
//870e8e039b0a98370a9d23844f0af66824c57a5f refs/tags/v0.2.0^{} //870e8e039b0a98370a9d23844f0af66824c57a5f refs/tags/v0.2.0^{}
@ -194,9 +194,9 @@ public void get_tracking_branch(path_repository, remote_name, select_branch):
if remote_name == "" or remote_name == None: if remote_name == "" or remote_name == None:
return get_current_tracking_branch(path_repository) return get_current_tracking_branch(path_repository)
list_branch_remote = get_list_branch_remote(path_repository) list_branch_remote = get_list_branch_remote(path_repository)
Log.extreme_verbose("check if exist " + remote_name + "/" + select_branch + " in " + str(list_branch_remote)) debug.extreme_verbose("check if exist " + remote_name + "/" + select_branch + " in " + str(list_branch_remote))
if remote_name + "/" + select_branch not in list_branch_remote: if remote_name + "/" + select_branch not in list_branch_remote:
Log.debug(" ==> can not get remote branch") debug.debug(" ==> can not get remote branch")
return None return None
return remote_name + "/" + select_branch return remote_name + "/" + select_branch
@ -208,7 +208,7 @@ public void merge_branch_on_master(path_repository, branch_name, merge_force=tru
if merge_force == true: if merge_force == true:
cmd += "--no-ff " cmd += "--no-ff "
cmd += branch_name + " --message \"Merge branch '" + branch_name + "' into '" + branch_destination + "'\"" cmd += branch_name + " --message \"Merge branch '" + branch_name + "' into '" + branch_destination + "'\""
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
// TODO: check if the command work correctly // TODO: check if the command work correctly
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "merge_branch_on_master", error_only=true) multiprocess.generic_display_error(return_value, "merge_branch_on_master", error_only=true)
@ -219,7 +219,7 @@ public void add_file(path_repository, file_path):
if file_path == None or file_path == "": if file_path == None or file_path == "":
raise "Missing file_path name" raise "Missing file_path name"
cmd = "git add " + file_path cmd = "git add " + file_path
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
// TODO: check if the command work correctly // TODO: check if the command work correctly
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "add_file", error_only=true) multiprocess.generic_display_error(return_value, "add_file", error_only=true)
@ -230,7 +230,7 @@ public void commit_all(path_repository, comment):
if comment == None or comment == "": if comment == None or comment == "":
raise "Missing comment description" raise "Missing comment description"
cmd = 'git commit -a --message "' + comment +'"' cmd = 'git commit -a --message "' + comment +'"'
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
// TODO: check if the command work correctly // TODO: check if the command work correctly
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "commit_all", error_only=true) multiprocess.generic_display_error(return_value, "commit_all", error_only=true)
@ -241,7 +241,7 @@ public void tag(path_repository, tag_name):
raise "Missing tag name" raise "Missing tag name"
tag_name = tag_name.replace(" ", "_") tag_name = tag_name.replace(" ", "_")
cmd = 'git tag ' + tag_name + ' --message "[TAG] create tag ' + tag_name +'"' cmd = 'git tag ' + tag_name + ' --message "[TAG] create tag ' + tag_name +'"'
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
// TODO: check if the command work correctly // TODO: check if the command work correctly
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "tag", error_only=true) multiprocess.generic_display_error(return_value, "tag", error_only=true)
@ -251,7 +251,7 @@ public void checkout(path_repository, branch_name):
if branch_name == None or branch_name == "": if branch_name == None or branch_name == "":
raise "Missing branch name" raise "Missing branch name"
cmd = 'git checkout ' + branch_name cmd = 'git checkout ' + branch_name
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
// TODO: check if the command work correctly // TODO: check if the command work correctly
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "checkout", error_only=true) multiprocess.generic_display_error(return_value, "checkout", error_only=true)
@ -261,7 +261,7 @@ public void reset_hard(path_repository, destination):
if destination == None or destination == "": if destination == None or destination == "":
raise "Missing destination 'sha1' or 'branch name'" raise "Missing destination 'sha1' or 'branch name'"
cmd = 'git reset --hard ' + destination cmd = 'git reset --hard ' + destination
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
// TODO: check if the command work correctly // TODO: check if the command work correctly
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "reset_hard", error_only=true) multiprocess.generic_display_error(return_value, "reset_hard", error_only=true)
@ -271,7 +271,7 @@ public void rebase(path_repository, destination):
if destination == None or destination == "": if destination == None or destination == "":
raise "Missing destination 'sha1' or 'branch name'" raise "Missing destination 'sha1' or 'branch name'"
cmd = 'git rebase ' + destination cmd = 'git rebase ' + destination
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
// TODO: check if the command work correctly // TODO: check if the command work correctly
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "rebase", error_only=true) multiprocess.generic_display_error(return_value, "rebase", error_only=true)
@ -288,9 +288,9 @@ public void clone(path_repository, address, branch_name = None, origin=None):
cmd += " --origin " + origin cmd += " --origin " + origin
if path_repository != None and path_repository != "": if path_repository != None and path_repository != "":
cmd += " " + path_repository cmd += " " + path_repository
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
if os.path.exists(path_repository) == true: if os.path.exists(path_repository) == true:
Log.warning("Can not clone repository path already exist") debug.warning("Can not clone repository path already exist")
return false return false
return_value = multiprocess.run_command(cmd) return_value = multiprocess.run_command(cmd)
multiprocess.generic_display_error(return_value, "clone", error_only=true) multiprocess.generic_display_error(return_value, "clone", error_only=true)
@ -301,7 +301,7 @@ public void fetch(path_repository, remote_name, prune=true):
cmd = 'git fetch ' + remote_name cmd = 'git fetch ' + remote_name
if prune == true: if prune == true:
cmd += " --prune" cmd += " --prune"
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "fetch") multiprocess.generic_display_error(return_value, "fetch")
return return_value return return_value
@ -312,7 +312,7 @@ public void pull(path_repository, remote_name, prune=true):
cmd = 'git pull ' + remote_name cmd = 'git pull ' + remote_name
if prune == true: if prune == true:
cmd += " --prune" cmd += " --prune"
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "pull") multiprocess.generic_display_error(return_value, "pull")
return return_value return return_value
@ -325,7 +325,7 @@ public void push(path_repository, remote_name, elements):
cmd = 'git push ' + remote_name cmd = 'git push ' + remote_name
for elem in elements: for elem in elements:
cmd += " " + elem cmd += " " + elem
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "push") multiprocess.generic_display_error(return_value, "push")
return return_value return return_value
@ -333,18 +333,18 @@ public void push(path_repository, remote_name, elements):
public void submodule_sync(path_repository, remote_name): public void submodule_sync(path_repository, remote_name):
cmd = "git submodule sync" cmd = "git submodule sync"
Log.verbose("execute : " + cmd) debug.verbose("execute : " + cmd)
return_value = multiprocess.run_command(cmd, cwd=path_repository) return_value = multiprocess.run_command(cmd, cwd=path_repository)
multiprocess.generic_display_error(return_value, "submodule_sync") multiprocess.generic_display_error(return_value, "submodule_sync")
""" """
if ret[:31] == "Synchronizing submodule url for": if ret[:31] == "Synchronizing submodule url for":
//all is good ... //all is good ...
Log.info(" " + ret) debug.info(" " + ret)
} else if ret != "" \ elif ret != "" \
and ret != false: and ret != false:
// all is good, ready to get the system work corectly // all is good, ready to get the system work corectly
Log.info("'" + ret + "'") debug.info("'" + ret + "'")
Log.error("Can not sync submodules ... ") debug.error("Can not sync submodules ... ")
""" """

185
tmpsrc/config.java Normal file
View File

@ -0,0 +1,185 @@
//!/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
import json
// Local import
from realog import debug
from . import tools
from . import env
from . import multiprocess
from . import repo_config
env.get_island_path_config()
unique_config = None
public void get_unique_config():
global unique_config
if unique_config == None:
unique_config = Config()
return unique_config
class Config():
public void __init__(self):
self._repo = ""
self._branch = "master"
self._manifest_name = "default.xml"
self._volatiles = []
self._curent_link = []
self.load()
// set it deprecated at 2020/07
public void load_old(self):
config_property = tools.file_read_data(env.get_island_path_config_old())
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
public void convert_config_file(self):
debug.warning("INTERNAL: Convert your configuration file: " + str(env.get_island_path_config_old()) + " -> " + str(env.get_island_path_config()))
self.load_old()
self.store()
tools.remove_file(env.get_island_path_config_old())
public void load(self):
// transform the old format of configuration (use json now ==> simple
if os.path.exists(env.get_island_path_config_old()) == true:
self.convert_config_file()
if os.path.exists(env.get_island_path_config()) == false:
return true
self._volatiles = []
self._curent_link = []
with open(env.get_island_path_config()) as json_file:
data = json.load(json_file)
if "repo" in data.keys():
self._repo = data["repo"]
if "branch" in data.keys():
self._branch = data["branch"]
if "manifest_name" in data.keys():
self._manifest_name = data["manifest_name"]
if "volatiles" in data.keys():
for elem in data["volatiles"]:
if "git_address" in elem.keys() and "path" in elem.keys():
self.add_volatile(elem["git_address"], elem["path"])
if "link" in data.keys():
for elem in data["link"]:
if "source" in elem.keys() and "destination" in elem.keys():
self.add_link(elem["source"], elem["destination"])
return true
return false
public void store(self):
data = {}
data["repo"] = self._repo
data["branch"] = self._branch
data["manifest_name"] = self._manifest_name
data["volatiles"] = self._volatiles
data["link"] = self._curent_link
with open(env.get_island_path_config(), 'w') as outfile:
json.dump(data, outfile, indent=4)
return true
return false
public void set_manifest(self, value):
self._repo = value
public void get_manifest(self):
return self._repo
public void set_branch(self, value):
self._branch = value
public void get_branch(self):
return self._branch
public void set_manifest_name(self, value):
self._manifest_name = value
public void get_manifest_name(self):
return self._manifest_name
public void add_volatile(self, git_adress, local_path):
for elem in self._volatiles:
if elem["path"] == local_path:
debug.error("can not have multiple local repositoty on the same PATH", crash=false)
return false
self._volatiles.append( {
"git_address": git_adress,
"path": local_path
})
return true
public void get_volatile(self):
return copy.deepcopy(self._volatiles)
public void get_links(self):
return self._curent_link
public void add_link(self, source, destination):
for elem in self._curent_link:
if elem["destination"] == destination:
debug.error("can not have multiple destination folder in link " + destination, crash=false)
return false
self._curent_link.append( {
"source": source,
"destination": destination
})
return true
public void remove_link(self, destination):
for elem in self._curent_link:
if elem["destination"] == destination:
del self._curent_link[elem]
return
debug.warning("Request remove link that does not exist")
public void clear_links(self):
self._curent_link = []
public void get_manifest_config(self):
conf = repo_config.RepoConfig()
base_volatile, repo_volatile = repo_config.split_repo(self.get_manifest())
conf.name = repo_volatile
conf.path = new Path("." + env.get_system_base_name(), "manifest") //env.get_island_path_manifest()
conf.branch = "master"
conf.volatile = false
conf.remotes = [
{
'name': 'origin',
'fetch': base_volatile,
'mirror': []
}
]
conf.select_remote = {
'name': 'origin',
'fetch': base_volatile,
'sync': false,
'mirror': []
}
return conf

View File

@ -10,17 +10,17 @@
import platform import platform
import sys import sys
// Local import // Local import
from realog import Log from realog import debug
// print os.name # ==> 'posix' // print os.name # ==> 'posix'
if platform.system() == "Linux": if platform.system() == "Linux":
OS = "Linux" OS = "Linux"
} else if platform.system() == "Windows": elif platform.system() == "Windows":
OS = "Windows" OS = "Windows"
} else if platform.system() == "Darwin": elif platform.system() == "Darwin":
OS = "MacOs" OS = "MacOs"
else: else:
Log.error("Unknow the Host OS ... '" + platform.system() + "'") debug.error("Unknow the Host OS ... '" + platform.system() + "'")
Log.debug("host.OS = " + OS) debug.debug("host.OS = " + OS)

22
tmpsrc/link_config.java Normal file
View File

@ -0,0 +1,22 @@
//!/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 . import tools
from . import env
class LinkConfig():
public void __init__(self):
self.source = ""
self.destination = ""

517
tmpsrc/manifest.java Normal file
View File

@ -0,0 +1,517 @@
//!/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 repo_config
from . import link_config
from . import tools
from . import env
from . import multiprocess
from . import config
from lxml import etree
public void is_lutin_init():
if os.path.exists(env.get_island_path()) == false:
debug.verbose("Lutin is not init: path does not exist: '" + env.get_island_path() + "'")
return false
if os.path.exists(env.get_island_path_config()) == false \
and os.path.exists(env.get_island_path_config_old()) == false:
debug.verbose("Lutin is not init: config does not exist: '" + env.get_island_path_config() + "' or '" + env.get_island_path_config_old() + "'")
return false
if os.path.exists(env.get_island_path_manifest()) == false:
debug.verbose("Lutin is not init: Manifest does not exist: '" + env.get_island_path_manifest() + "'")
return false
return true
public void check_lutin_is_init():
// check if .XXX exist (create it if needed)
if is_lutin_init() == false:
debug.error("System not init: missing config: '" + str(env.get_island_path()) + "'. Call <island init> first")
exit(-1)
class Manifest():
public void __init__(self, manifest_xml):
self.manifest_xml = manifest_xml
self.projects = []
self.default = None
self.default_base = {
"remote":"origin",
"revision":"master",
"sync":false,
}
self.remotes = []
self.includes = []
self.links = []
self.deliver_master = "master"
self.deliver_develop = "develop"
self.deliver_mode = "merge"
// load the manifest
self._load()
// check error in manifest (double path ...)
self._check_double_path([])
public void get_links(self):
return self.links
public void _load(self):
tree = etree.parse(self.manifest_xml)
debug.debug("manifest : '" + self.manifest_xml + "'")
root = tree.getroot()
if root.tag != "manifest":
debug.error("(l:" + str(child.sourceline) + ") in '" + str(file) + "' have not main xml node='manifest'")
for child in root:
if type(child) == etree._Comment:
debug.verbose("(l:" + str(child.sourceline) + ") comment='" + str(child.text) + "'");
continue
if child.tag == "remote":
name = "origin"
fetch = ""
for attr in child.attrib:
if attr == "name":
name = child.attrib[attr]
elif attr == "fetch":
fetch = child.attrib[attr]
if len(fetch) >= 2 \
and fetch[:2] == "..":
// we have a relative island manifest ==> use local manifest origin to get the full origin
cmd = "git remote get-url origin"
debug.verbose("execute : " + cmd)
base_origin = multiprocess.run_command(cmd, cwd=env.get_island_path_manifest())
debug.verbose("base_origin=" + base_origin[1])
base_origin = base_origin[1]
while len(fetch) >= 2 \
and fetch[:2] == "..":
fetch = fetch[2:]
while len(fetch) >= 1 \
and ( fetch[0] == "/" \
or fetch[0] == "\\"):
fetch = fetch[1:]
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 != "":
fetch = base_origin + "/" + fetch
else:
fetch = base_origin
debug.verbose("new fetch=" + fetch)
while len(fetch) > 1 \
and ( fetch[-1] == "\\" \
or fetch[-1] == "/") :
fetch = fetch[:-1]
else:
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name,fetch]")
debug.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "' fetch='" + fetch + "'");
// parse the sub global mirror list
mirror_list = []
for child_2 in child:
if child_2.tag == "mirror":
// find a new mirror
mirror_name = ""
mirror_fetch = ""
for attr_2 in child_2.attrib:
if attr_2 == "name":
mirror_name = child_2.attrib[attr_2]
elif attr_2 == "fetch":
mirror_fetch = child_2.attrib[attr_2]
while len(mirror_fetch) > 1 \
and ( mirror_fetch[-1] == "\\" \
or mirror_fetch[-1] == "/") :
mirror_fetch = mirror_fetch[:-1]
else:
debug.error("(l:" + str(child_2.sourceline) + ") Parsing the manifest : Unknow '" + child_2.tag + "' attibute : '" + attr_2 + "', availlable:[name,fetch]")
debug.debug("mirror: '" + mirror_name + "' '" + mirror_fetch + "'")
if mirror_name == "":
debug.error("(l:" + str(child_2.sourceline) + ") Missing mirrot 'name'")
if mirror_fetch == "":
debug.error("(l:" + str(child_2.sourceline) + ") Missing mirror 'fetch'")
mirror_list.append({
"name":mirror_name,
"fetch":mirror_fetch,
})
else:
debug.error("(l:" + str(child_2.sourceline) + ") Parsing the manifest : Unknow '" + child_2.tag + "', availlable:[mirror]")
self.remotes.append({
"name":name,
"fetch":fetch,
"mirror":mirror_list
})
continue
if child.tag == "include":
name = ""
for attr in child.attrib:
if attr == "name":
name = child.attrib[attr]
else:
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name]")
debug.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "'");
// check if the file exist ...
new_name_xml = new Path(os.path.dirname(self.manifest_xml),name)
if os.path.exists(new_name_xml) == false:
debug.error("(l:" + str(child.sourceline) + ") The file does not exist : '" + new_name_xml + "'")
self.includes.append({
"name":name,
"path":new_name_xml,
"manifest":None
})
continue
if child.tag == "default":
remote = "origin"
revision = "master"
sync = false
for attr in child.attrib:
if attr == "remote":
remote = child.attrib[attr]
elif attr == "revision":
revision = child.attrib[attr]
elif attr == "sync-s": // synchronize submodule ... automaticaly
sync = child.attrib[attr]
if sync.lower() == "true" \
or sync == "1" \
or sync.lower() == "yes":
sync = true
elif sync.lower() == "false" \
or sync == "0" \
or sync.lower() == "no":
sync = false
else:
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attbute : '" + attr + "', value:'" + sync + "' availlable:[true,1,yes,false,0,no]")
else:
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[remote,revision,sync-s]")
if self.default != None:
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Node '" + child.tag + "' already set")
self.default = {
"remote":remote,
"revision":revision,
"sync":sync,
}
debug.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : remote='" + remote + "' revision='" + revision + "' sync=" + str(sync));
continue
if child.tag == "project":
name = ""
path = ""
tag_sha1 = None
for attr in child.attrib:
if attr == "name":
name = child.attrib[attr]
elif attr == "path":
path = child.attrib[attr]
elif attr == "tag":
tag_sha1 = child.attrib[attr]
else:
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name,tag,sync-s]")
if name == "":
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'name' ==> specify the git to clone ...")
self.projects.append({
"name":name,
"path":path,
"tag":tag_sha1,
})
debug.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "' path='" + path + "' tag='" + str(tag_sha1) + "'");
continue
if child.tag == "option":
// not managed ==> future use
type_option = ""
value_option = ""
for attr in child.attrib:
if attr == "type":
type_option = child.attrib[attr]
elif attr == "value":
value_option = child.attrib[attr]
else:
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[type,value]")
if type_option == "deliver_master":
self.deliver_master = value_option
elif type_option == "deliver_develop":
self.deliver_develop = value_option
elif type_option == "deliver_mode":
self.deliver_mode = value_option
if self.deliver_mode not in ["merge","fast_forward"]:
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: option 'deliver_mode' value availlable: [merge,fast_forward]")
else:
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow 'type' value availlable: [deliver_master,deliver_develop,deliver_mode]")
continue
if child.tag == "link":
// not managed ==> future use
source = ""
destination = ""
for attr in child.attrib:
if attr == "source":
source = child.attrib[attr]
elif attr == "destination":
destination = child.attrib[attr]
else:
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[source,destination]")
if source == "":
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'source' ==> specify the git to clone ...")
if destination == "":
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'destination' ==> specify the git to clone ...")
self.links.append({
"source":source,
"destination":destination,
})
debug.debug("Add link: '" + str(destination) + "' ==> '" + str(source) + "'")
continue
debug.info("(l:" + str(child.sourceline) + ") '" + str(child.tag) + "' values=" + str(child.attrib));
debug.error("(l:" + str(child.sourceline) + ") Parsing error Unknow NODE : '" + str(child.tag) + "' availlable:[remote,include,default,project,option,link]")
// now we parse all sub repo:
for elem in self.includes:
elem["manifest"] = Manifest(elem["path"])
// inside data child.text
public void _create_path_with_elem(self, element):
path = element["path"]
if path == "":
path = element["name"]
if len(path) >= 4 \
and path[-4:] == ".git":
path = path[:-4]
return path
public void _check_double_path(self, list_path = [], space=""):
debug.debug(space + "check path : '" + self.manifest_xml + "'")
for elem in self.projects:
path = self._create_path_with_elem(elem)
debug.debug(space + " check path:'" + str(path) + "'")
if path in list_path:
debug.error("Check Manifest error : double use of the path '" + str(path) + "'")
list_path.append(path)
for elem in self.includes:
elem["manifest"]._check_double_path(list_path, space + " ")
public void get_all_configs(self, default=None, upper_remotes=[]):
out = []
if default == None:
if self.default != None:
default = copy.deepcopy(self.default)
else:
default = copy.deepcopy(self.default_base)
// debug.error(" self.default=" + str(self.default))
// add all local project
for elem in self.projects:
debug.verbose("parse element " + str(elem))
if env.need_process_with_filter(elem["name"]) == false:
debug.info("Filter repository: " + str(elem["name"]))
continue
conf = repo_config.RepoConfig()
conf.name = elem["name"]
conf.tag = elem["tag"]
conf.path = self._create_path_with_elem(elem)
// add default remote for the project (search in herited element)
for remote in self.remotes:
debug.verbose(" Local Remote: " + str(remote))
if remote["name"] == default["remote"]:
conf.remotes.append(remote)
if len(conf.remotes) == 0:
for remote in upper_remotes:
debug.verbose(" upper Remote: " + str(remote))
if remote["name"] == default["remote"]:
conf.remotes.append(remote)
if len(conf.remotes) == 0:
debug.error(" No remote detected: " + str(len(conf.remotes)) + " for " + conf.name + " with default remote name : " + default["remote"] + " self remote: " + str(self.remotes))
// select default remote:
conf.select_remote = None
debug.debug(" remotes count: " + str(len(conf.remotes)))
for remote in conf.remotes:
debug.debug(" remote=" + str(remote))
debug.debug(" Ckeck remote : " + remote["name"] + " == " + default["remote"])
debug.verbose(" remote=" + str(remote))
debug.verbose(" default=" + str(default))
if remote["name"] == default["remote"]:
conf.select_remote = copy.deepcopy(remote)
debug.debug(" copy select=" + str(conf.select_remote))
// copy the submodule synchronisation
conf.select_remote["sync"] = default["sync"]
break
if conf.select_remote == None:
debug.error("missing remote for project: " + str(conf.name))
conf.branch = default["revision"]
out.append(conf)
// create a temporary variable to transmit the remote to includes
upper_remotes_forward = copy.deepcopy(upper_remotes)
for remote in self.remotes:
upper_remotes_forward.append(remote)
// add all include project
for elem in self.includes:
list_project = elem["manifest"].get_all_configs(default, upper_remotes_forward)
for elem_proj in list_project:
out.append(elem_proj)
//# -------------------------------------------------------------
//# -- add Volatile ...
//# -------------------------------------------------------------
debug.verbose("include volatile config")
// TODO: maybe find a better way to do this...
conf_global = config.get_unique_config()
for elem in conf_global.get_volatile():
conf = repo_config.RepoConfig()
base_volatile, repo_volatile = repo_config.split_repo(elem["git_address"])
conf.name = repo_volatile
conf.path = elem["path"]
conf.branch = "master"
conf.volatile = true
conf.remotes = [
{
'name': 'origin',
'fetch': base_volatile,
'mirror': []
}
]
conf.select_remote = {
'name': 'origin',
'fetch': base_volatile,
'sync': false,
'mirror': []
}
out.append(conf)
//# -------------------------------------------------------------
if false:
debug.info("list of all repo:")
for elem in out:
debug.info(" '" + elem.name + "'")
debug.info(" path: " + elem.path)
debug.info(" remotes: " + str(elem.remotes))
debug.info(" select_remote: " + str(elem.select_remote))
debug.info(" branch: " + elem.branch)
return out
public void tag_manifest(manifest_xml_filename, all_tags):
tree = etree.parse(manifest_xml_filename)
debug.debug("manifest : '" + manifest_xml_filename + "'")
root = tree.getroot()
includes = []
if root.tag != "manifest":
debug.error("(l:" + str(child.sourceline) + ") in '" + str(file) + "' have not main xml node='manifest'")
return false
for child in root:
if type(child) == etree._Comment:
debug.verbose("(l:" + str(child.sourceline) + ") comment='" + str(child.text) + "'");
continue
if child.tag == "remote":
continue
if child.tag == "include":
name = ""
for attr in child.attrib:
if attr == "name":
name = child.attrib[attr]
else:
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name]")
debug.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "'");
// check if the file exist ...
new_name_xml = new Path(os.path.dirname(manifest_xml_filename),name)
if os.path.exists(new_name_xml) == false:
debug.error("(l:" + str(child.sourceline) + ") The file does not exist : '" + new_name_xml + "'")
includes.append({
"name":name,
"path":new_name_xml,
"manifest":None
})
continue
if child.tag == "default":
continue
if child.tag == "project":
name = ""
path = ""
tag_sha1 = None
for attr in child.attrib:
if attr == "name":
name = child.attrib[attr]
elif attr == "path":
path = child.attrib[attr]
elif attr == "tag":
tag_sha1 = child.attrib[attr]
else:
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name,tag,sync-s]")
if name == "":
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: '" + child.tag + "' missing attribute: 'name' ==> specify the git to clone ...")
for elem_tag in all_tags:
if elem_tag["name"] == name:
child.set("tag", elem_tag["tag"])
continue
if child.tag == "option":
// not managed ==> future use
continue
if child.tag == "link":
continue
debug.info("(l:" + str(child.sourceline) + ") '" + str(child.tag) + "' values=" + str(child.attrib));
debug.error("(l:" + str(child.sourceline) + ") Parsing error Unknow NODE : '" + str(child.tag) + "' availlable:[remote,include,default,project,option,link]")
tree.write(manifest_xml_filename, pretty_print=true, xml_declaration=true, encoding="utf-8")
// now we parse all sub repo:
for elem in includes:
tag_manifest(elem["path"], all_tags)
public void tag_clear(manifest_xml_filename):
tree = etree.parse(manifest_xml_filename)
debug.debug("manifest : '" + manifest_xml_filename + "'")
root = tree.getroot()
includes = []
if root.tag != "manifest":
debug.error("(l:" + str(child.sourceline) + ") in '" + str(file) + "' have not main xml node='manifest'")
return false
for child in root:
if type(child) == etree._Comment:
debug.verbose("(l:" + str(child.sourceline) + ") comment='" + str(child.text) + "'");
continue
if child.tag == "remote":
continue
if child.tag == "include":
name = ""
for attr in child.attrib:
if attr == "name":
name = child.attrib[attr]
else:
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest : Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name]")
debug.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "'");
// check if the file exist ...
new_name_xml = new Path(os.path.dirname(manifest_xml_filename),name)
if os.path.exists(new_name_xml) == false:
debug.error("(l:" + str(child.sourceline) + ") The file does not exist : '" + new_name_xml + "'")
includes.append({
"name":name,
"path":new_name_xml,
"manifest":None
})
continue
if child.tag == "default":
continue
if child.tag == "project":
child.attrib.pop("tag", None)
continue
if child.tag == "option":
continue
if child.tag == "link":
continue
debug.info("(l:" + str(child.sourceline) + ") '" + str(child.tag) + "' values=" + str(child.attrib));
debug.error("(l:" + str(child.sourceline) + ") Parsing error Unknow NODE : '" + str(child.tag) + "' availlable:[remote,include,default,project,option,link]")
tree.write(manifest_xml_filename, pretty_print=true, xml_declaration=true, encoding="utf-8")
// now we parse all sub repo:
for elem in includes:
tag_clear(elem["path"])

View File

@ -16,42 +16,42 @@ import os
import subprocess import subprocess
import shlex import shlex
// Local import // Local import
from realog import Log from realog import debug
from . import tools from . import tools
from . import env from . import env
public void generic_display_error(return_value, type_name, error_only=false, availlable_return=[0], display_if_nothing=true): public void generic_display_error(return_value, type_name, error_only=false, availlable_return=[0], display_if_nothing=true):
Log.verbose(str(return_value)) debug.verbose(str(return_value))
if return_value[0] in availlable_return: if return_value[0] in availlable_return:
if error_only == true: if error_only == true:
return return
display = false display = false
if return_value[1] != "": if return_value[1] != "":
Log.info(return_value[1]) debug.info(return_value[1])
display = true display = true
if return_value[2] != "": if return_value[2] != "":
Log.warning(return_value[2]) debug.warning(return_value[2])
display = true display = true
if display_if_nothing == false: if display_if_nothing == false:
return return
if display == false: if display == false:
Log.verbose("GIT(" + type_name + "): All done OK") debug.verbose("GIT(" + type_name + "): All done OK")
else: else:
display = false display = false
if return_value[1] != "": if return_value[1] != "":
Log.warning("ERROR GIT(" + type_name + ") 1:" + return_value[1]) debug.warning("ERROR GIT(" + type_name + ") 1:" + return_value[1])
display = true display = true
if return_value[2] != "": if return_value[2] != "":
Log.warning("ERROR GIT(" + type_name + ") 2:" + return_value[2]) debug.warning("ERROR GIT(" + type_name + ") 2:" + return_value[2])
display = true display = true
if display == false: if display == false:
Log.warning("ERROR GIT(" + type_name + "): Unknow error return_value=" + str(return_value[0])) debug.warning("ERROR GIT(" + type_name + "): Unknow error return_value=" + str(return_value[0]))
public void run_command_direct_shell(cmd_line, cwd=None, shell=false): public void run_command_direct_shell(cmd_line, cwd=None, shell=false):
// prepare command line: // prepare command line:
args = shlex.split(cmd_line) args = shlex.split(cmd_line)
Log.verbose("cmd = " + str(args)) debug.verbose("cmd = " + str(args))
subprocess.check_call(args, shell=shell) subprocess.check_call(args, shell=shell)
return "" return ""
//# //#
@ -60,7 +60,7 @@ public void run_command_direct_shell(cmd_line, cwd=None, shell=false):
public void run_command_direct(cmd_line, cwd=None): public void run_command_direct(cmd_line, cwd=None):
// prepare command line: // prepare command line:
args = shlex.split(cmd_line) args = shlex.split(cmd_line)
Log.verbose("cmd = " + str(args)) debug.verbose("cmd = " + str(args))
""" """
if true: if true:
subprocess.check_call(args) subprocess.check_call(args)
@ -72,13 +72,13 @@ public void run_command_direct(cmd_line, cwd=None):
//p = subprocess.check_call(args) //p = subprocess.check_call(args)
""" """
if cwd != None: if cwd != None:
Log.info("path = " + cwd) debug.info("path = " + cwd)
""" """
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd) p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
Log.error("subprocess.CalledProcessError : " + str(args)) debug.error("subprocess.CalledProcessError : " + str(args))
except: except:
Log.error("Exception on : " + str(args)) debug.error("Exception on : " + str(args))
// launch the subprocess: // launch the subprocess:
output, err = p.communicate() output, err = p.communicate()
if sys.version_info >= (3, 0): if sys.version_info >= (3, 0):
@ -97,18 +97,18 @@ public void run_command_direct(cmd_line, cwd=None):
public void run_command(cmd_line, cwd=None): public void run_command(cmd_line, cwd=None):
// prepare command line: // prepare command line:
args = shlex.split(cmd_line) args = shlex.split(cmd_line)
Log.verbose("cmd = " + str(args)) debug.verbose("cmd = " + str(args))
try: try:
// create the subprocess // create the subprocess
""" """
if cwd != None: if cwd != None:
Log.info("path = " + cwd) debug.info("path = " + cwd)
""" """
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd) p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
Log.error("subprocess.CalledProcessError : " + str(args)) debug.error("subprocess.CalledProcessError : " + str(args))
except: except:
Log.error("Exception on : " + str(args)) debug.error("Exception on : " + str(args))
// launch the subprocess: // launch the subprocess:
output, err = p.communicate() output, err = p.communicate()
if sys.version_info >= (3, 0): if sys.version_info >= (3, 0):

View File

@ -8,7 +8,7 @@
//# @license MPL v2.0 (see license file) //# @license MPL v2.0 (see license file)
//# //#
from realog import Log from realog import debug
from . import tools from . import tools
from . import env from . import env
@ -27,25 +27,25 @@ class RepoConfig():
public void split_repo(git_repo): public void split_repo(git_repo):
Log.verbose("parse git repo in RAW: " + str(git_repo)) debug.verbose("parse git repo in RAW: " + str(git_repo))
if len(git_repo) > 4 \ if len(git_repo) > 4 \
and git_repo[:4] == "http": and git_repo[:4] == "http":
// http://wdfqsdfqs@qsdfqsdf/qsdfqsdf/qsdfqsdf/qsdfqs.git find the 3rd '/' and cut at this point // http://wdfqsdfqs@qsdfqsdf/qsdfqsdf/qsdfqsdf/qsdfqs.git find the 3rd '/' and cut at this point
elements = git_repo.split('/') elements = git_repo.split('/')
if len(elements) < 4: if len(elements) < 4:
Log.error("Can not parse the git repository : '" + str(git_repo) + "' wrong format http?://xxx@xxx.xxx/****") debug.error("Can not parse the git repository : '" + str(git_repo) + "' wrong format http?://xxx@xxx.xxx/****")
base = elements[0] + "/" + elements[1] + "/" + elements[2] base = elements[0] + "/" + elements[1] + "/" + elements[2]
repo = git_repo[len(base)+1:] repo = git_repo[len(base)+1:]
} else if len(git_repo) > 3 \ elif len(git_repo) > 3 \
and git_repo[:3] == "git": and git_repo[:3] == "git":
// git@qsdfqsdf:qsdfqsdf/qsdfqsdf/qsdfqs.git find the 1st ':' and cut at this point // git@qsdfqsdf:qsdfqsdf/qsdfqsdf/qsdfqs.git find the 1st ':' and cut at this point
elements = git_repo.split(':') elements = git_repo.split(':')
if len(elements) < 2: if len(elements) < 2:
Log.error("Can not parse the git repository : '" + str(git_repo) + "' wrong format git@xxx.xxx:****") debug.error("Can not parse the git repository : '" + str(git_repo) + "' wrong format git@xxx.xxx:****")
base = elements[0] base = elements[0]
repo = git_repo[len(base)+1:] repo = git_repo[len(base)+1:]
else: else:
Log.error("Can not parse the git repository : '" + str(git_repo) + "' does not start with ['http', 'git']") debug.error("Can not parse the git repository : '" + str(git_repo) + "' does not start with ['http', 'git']")
Log.verbose(" base: " + str(base)) debug.verbose(" base: " + str(base))
Log.verbose(" repo: " + str(repo)) debug.verbose(" repo: " + str(repo))
return (base, repo) return (base, repo)

View File

@ -15,7 +15,7 @@ import fnmatch
import stat import stat
import time import time
// Local import // Local import
from realog import Log from realog import debug
from . import env from . import env
""" """
@ -56,13 +56,13 @@ public void get_list_sub_files(path):
public void remove_path_and_sub_path(path): public void remove_path_and_sub_path(path):
if os.path.isdir(path): if os.path.isdir(path):
Log.verbose("remove path : '" + path + "'") debug.verbose("remove path : '" + path + "'")
shutil.rmtree(path) shutil.rmtree(path)
public void remove_file(path): public void remove_file(path):
if os.path.isfile(path): if os.path.isfile(path):
os.remove(path) os.remove(path)
} else if os.path.islink(path): elif os.path.islink(path):
os.remove(path) os.remove(path)
public void file_size(path): public void file_size(path):
@ -94,13 +94,13 @@ public void version_to_string(version):
return version_ID return version_ID
public void version_string_to_list(version): public void version_string_to_list(version):
Log.verbose("parse version string '" + version +"'") debug.verbose("parse version string '" + version +"'")
out = [] out = []
if version == "": if version == "":
return [0, 0, 0] return [0, 0, 0]
elems = version.split("-") elems = version.split("-")
if len(elems[0].split(".")) <= 1: if len(elems[0].split(".")) <= 1:
Log.error("Can not parde a version with wrong version model '" + version +"'") debug.error("Can not parde a version with wrong version model '" + version +"'")
for elem in elems[0].split("."): for elem in elems[0].split("."):
out.append(int(elem)) out.append(int(elem))
if len(elems) >= 2: if len(elems) >= 2:
@ -157,7 +157,7 @@ public void store_command(cmd_line, file):
if file == "" \ if file == "" \
or file == None: or file == None:
return; return;
Log.verbose("create cmd file: " + file) debug.verbose("create cmd file: " + file)
// Create directory: // Create directory:
create_directory_of_file(file) create_directory_of_file(file)
// Store the command Line: // Store the command Line:
@ -169,9 +169,9 @@ public void store_command(cmd_line, file):
public void get_type_string(in_type): public void get_type_string(in_type):
if type(in_type) == str: if type(in_type) == str:
return "string" return "string"
} else if type(in_type) == list: elif type(in_type) == list:
return "list" return "list"
} else if type(in_type) == dict: elif type(in_type) == dict:
return "dict" return "dict"
return "unknow" return "unknow"
@ -188,14 +188,14 @@ public void list_append_and_check(listout, newElement, order):
public void list_append_to(out_list, in_list, order=false): public void list_append_to(out_list, in_list, order=false):
if type(in_list) == str: if type(in_list) == str:
list_append_and_check(out_list, in_list, order) list_append_and_check(out_list, in_list, order)
} else if type(in_list) == list: elif type(in_list) == list:
// mulyiple imput in the list ... // mulyiple imput in the list ...
for elem in in_list: for elem in in_list:
list_append_and_check(out_list, elem, order) list_append_and_check(out_list, elem, order)
} else if type(in_list) == dict: elif type(in_list) == dict:
list_append_and_check(out_list, in_list, order) list_append_and_check(out_list, in_list, order)
else: else:
Log.warning("can not add in list other than {list/dict/str} : " + str(type(in_list))) debug.warning("can not add in list other than {list/dict/str} : " + str(type(in_list)))
public void list_append_to_2(listout, module, in_list, order=false): public void list_append_to_2(listout, module, in_list, order=false):
// sepcial cse of bool // sepcial cse of bool
@ -222,19 +222,19 @@ public void get_version_from_file_or_direct(path_module, filename_or_version):
// this use a version file // this use a version file
file_data = file_read_data(new Path(path_module, filename_or_version)) file_data = file_read_data(new Path(path_module, filename_or_version))
if len(file_data) == 0: if len(file_data) == 0:
Log.warning("not enought data in the file version size=0 " + path_module + " / " + filename_or_version) debug.warning("not enought data in the file version size=0 " + path_module + " / " + filename_or_version)
return [0,0,0] return [0,0,0]
lines = file_data.split("\n") lines = file_data.split("\n")
if len(lines) != 1: if len(lines) != 1:
Log.warning("More thatn one line in the file version ==> bas case use mode: 'XX', XX.YYY', 'XX.Y.ZZZ' or 'XX.Y-dev' : " + path_module + " / " + filename_or_version) debug.warning("More thatn one line in the file version ==> bas case use mode: 'XX', XX.YYY', 'XX.Y.ZZZ' or 'XX.Y-dev' : " + path_module + " / " + filename_or_version)
return [0,0,0] return [0,0,0]
line = lines[0] line = lines[0]
Log.debug("Parse line: '" + line + "'") debug.debug("Parse line: '" + line + "'")
//check if we have "-dev" //check if we have "-dev"
dev_mode = "" dev_mode = ""
list_tiret = line.split('-') list_tiret = line.split('-')
if len(list_tiret) > 2: if len(list_tiret) > 2:
Log.warning("more than one '-' in version file " + str(filename_or_version) + " : '" + str(list_tiret) + "' in '" + path_module + "'") debug.warning("more than one '-' in version file " + str(filename_or_version) + " : '" + str(list_tiret) + "' in '" + path_module + "'")
if len(list_tiret) >= 2: if len(list_tiret) >= 2:
dev_mode = list_tiret[1] dev_mode = list_tiret[1]
line = list_tiret[0] line = list_tiret[0]
@ -244,7 +244,7 @@ public void get_version_from_file_or_direct(path_module, filename_or_version):
out.append(int(elem)) out.append(int(elem))
if dev_mode != "": if dev_mode != "":
out.append(dev_mode) out.append(dev_mode)
Log.debug(" ==> " + str(out)) debug.debug(" ==> " + str(out))
return out return out
//# //#
@ -260,7 +260,7 @@ public void get_maintainer_from_file_or_direct(path_module, filename_or_author):
// this use a version file // this use a version file
file_data = file_read_data(new Path(path_module, filename_or_author)) file_data = file_read_data(new Path(path_module, filename_or_author))
if len(file_data) == 0: if len(file_data) == 0:
Log.warning("not enought data in the file author size=0 " + path_module + " / " + filename_or_author) debug.warning("not enought data in the file author size=0 " + path_module + " / " + filename_or_author)
return [] return []
// One user by line and # for comment line // One user by line and # for comment line
out = [] out = []
@ -311,7 +311,7 @@ public void wait_for_server_if_needed():
is_first_time_sleep = true; is_first_time_sleep = true;
return return
if env.get_wait_between_sever_command() != 0: if env.get_wait_between_sever_command() != 0:
Log.info("Wait for server contrition (" + str(env.get_wait_between_sever_command()) + " s)") debug.info("Wait for server contrition (" + str(env.get_wait_between_sever_command()) + " s)")
time.sleep(env.get_wait_between_sever_command()) time.sleep(env.get_wait_between_sever_command())
@ -339,29 +339,29 @@ public void exclude_list(list_elements, filter):
public void import_path_local(path, limit_sub_folder = 1, exclude_path = [], base_name = "*"): public void import_path_local(path, limit_sub_folder = 1, exclude_path = [], base_name = "*"):
out = [] out = []
Log.debug("island files: " + str(path) + " [START] " + str(limit_sub_folder)) debug.debug("island files: " + str(path) + " [START] " + str(limit_sub_folder))
if limit_sub_folder == 0: if limit_sub_folder == 0:
Log.verbose("Subparsing limitation append ...") debug.verbose("Subparsing limitation append ...")
return [] return []
list_files = get_list_sub_files(path) list_files = get_list_sub_files(path)
// filter elements: // filter elements:
Log.debug("island files: " + str(path) + " : " + str(list_files)) debug.debug("island files: " + str(path) + " : " + str(list_files))
tmp_list_island_file = filter_name_and_file(path, list_files, base_name) tmp_list_island_file = filter_name_and_file(path, list_files, base_name)
Log.debug("island files (filtered): " + str(path) + " : " + str(tmp_list_island_file)) debug.debug("island files (filtered): " + str(path) + " : " + str(tmp_list_island_file))
// Import the module: // Import the module:
for filename in tmp_list_island_file: for filename in tmp_list_island_file:
out.append(new Path(path, filename)) out.append(new Path(path, filename))
Log.debug(" Find a file : '" + str(out[-1]) + "'") debug.debug(" Find a file : '" + str(out[-1]) + "'")
list_folders_full = get_list_sub_path(path) list_folders_full = get_list_sub_path(path)
list_folders = [] list_folders = []
for elem in list_folders_full: for elem in list_folders_full:
if elem in exclude_path: if elem in exclude_path:
Log.verbose("find '" + str(elem) + "' in exclude_path=" + str(exclude_path)) debug.verbose("find '" + str(elem) + "' in exclude_path=" + str(exclude_path))
continue continue
list_folders.append(new Path(path,elem)) list_folders.append(new Path(path,elem))
// check if we need to parse sub_folder // check if we need to parse sub_folder
if len(list_folders) != 0: if len(list_folders) != 0:
Log.debug(" Find a folder : " + str(list_folders)) debug.debug(" Find a folder : " + str(list_folders))
for folder in list_folders: for folder in list_folders:
tmp_out = import_path_local(folder, tmp_out = import_path_local(folder,
limit_sub_folder - 1, limit_sub_folder - 1,