Compare commits
90 Commits
Author | SHA1 | Date | |
---|---|---|---|
a9e1685d8d | |||
2435b99328 | |||
e8c5dc4da0 | |||
e604008a27 | |||
d646aab6f6 | |||
31f2815230 | |||
8c3c73f2ff | |||
4d15e21c12 | |||
8660b5b376 | |||
bd7f732ca2 | |||
3f51e9e35c | |||
78f559ec21 | |||
065b3ea6a7 | |||
42a432a004 | |||
833792cd81 | |||
8fb94175ae | |||
375c983df6 | |||
00b2544511 | |||
3e432ffc21 | |||
4c50fb154d | |||
d31e66ac73 | |||
d5d52537bd | |||
459910369e | |||
47a4209a8b | |||
531b793603 | |||
93a05a7145 | |||
49d415f26b | |||
c357fe0f35 | |||
a52d7a307b | |||
2a484d1ce2 | |||
3f49ad7fb3 | |||
5cc7e6b16a | |||
ff9ed410ad | |||
180f2968e7 | |||
ab38c6cccb | |||
4e0b7778b0 | |||
9f0584d6c3 | |||
7eb2a7d171 | |||
3a907784c5 | |||
785d8efd70 | |||
1f3959499c | |||
c342082394 | |||
aedbd09497 | |||
fe1a4ec667 | |||
88edb38d26 | |||
0593274392 | |||
daa5c8039d | |||
21650b55c8 | |||
fe93eb07f6 | |||
1177261c85 | |||
c7ab6ff5e5 | |||
cfab74dfa1 | |||
bfdcf41ac4 | |||
77cc304dac | |||
39a80ea719 | |||
e1899f89d0 | |||
e0ec2bddae | |||
27936e3ac1 | |||
e4ce48df7c | |||
4b094dfcca | |||
020dc8f8de | |||
8d7fd32714 | |||
10f40f4d00 | |||
1a7129d632 | |||
49874b7785 | |||
6fda840ae5 | |||
7a46b3c0f9 | |||
bc556ee89b | |||
7f88a7cc34 | |||
9f11499b34 | |||
6da4400509 | |||
0f47c841fd | |||
bc82c533f1 | |||
f8de06c4d9 | |||
1d70339f72 | |||
e3a8d32557 | |||
e1a8280e01 | |||
a605da450f | |||
94f79962c4 | |||
9086c073a1 | |||
d362d47889 | |||
f90e5bc535 | |||
badbafc4bf | |||
e916efde7b | |||
11e39de3bd | |||
910016f978 | |||
d3a542a957 | |||
9973c3b4d6 | |||
ec2bf05393 | |||
69ba49e66b |
69
README.rst
69
README.rst
@@ -1,25 +1,31 @@
|
||||
Lutin
|
||||
=====
|
||||
|
||||
`maestro` is a generic source downloader and syncronizer is a FREE software tool.
|
||||
`island` is a generic source downloader and syncronizer is a FREE software tool.
|
||||
|
||||
It is compatible with basic format of repo-git manifest. This project is created to be easyest to read with simple interface
|
||||
(no internal git usage, but user level git usage) The main point to create the "fork" is the non-support of repo of relativity
|
||||
in submodule of git (submodule reference with ../xxx.git) This point is really important when you want to have a rellocable
|
||||
manifest and project with submodule. The simpl eexample is the atria-soft / generic-library / musicdsp that are availlable on
|
||||
github, gitlab, bitbucket and personal server.
|
||||
|
||||
|
||||
.. image:: https://badge.fury.io/py/maestro.png
|
||||
:target: https://pypi.python.org/pypi/maestro
|
||||
.. image:: https://badge.fury.io/py/island.png
|
||||
:target: https://pypi.python.org/pypi/island
|
||||
|
||||
Release (master)
|
||||
----------------
|
||||
|
||||
.. image:: https://travis-ci.org/HeeroYui/maestro.svg?branch=master
|
||||
:target: https://travis-ci.org/HeeroYui/maestro
|
||||
.. image:: https://travis-ci.org/HeeroYui/island.svg?branch=master
|
||||
:target: https://travis-ci.org/HeeroYui/island
|
||||
|
||||
|
||||
|
||||
Developement (dev)
|
||||
------------------
|
||||
|
||||
.. image:: https://travis-ci.org/HeeroYui/maestro.svg?branch=dev
|
||||
:target: https://travis-ci.org/HeeroYui/maestro
|
||||
.. image:: https://travis-ci.org/HeeroYui/island.svg?branch=dev
|
||||
:target: https://travis-ci.org/HeeroYui/island
|
||||
|
||||
|
||||
Instructions
|
||||
@@ -27,18 +33,18 @@ Instructions
|
||||
|
||||
This is a tool to download ```git``` source repositiry in a versatile worktree
|
||||
|
||||
Maestro is under a FREE license that can be found in the LICENSE file.
|
||||
island is under a FREE license that can be found in the LICENSE file.
|
||||
Any contribution is more than welcome ;)
|
||||
|
||||
git repository
|
||||
--------------
|
||||
|
||||
http://github.com/HeeroYui/maestro/
|
||||
http://github.com/HeeroYui/island/
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
http://HeeroYui.github.io/maestro/
|
||||
http://HeeroYui.github.io/island/
|
||||
|
||||
Installation
|
||||
------------
|
||||
@@ -47,7 +53,7 @@ Requirements: ``Python >= 2.7`` and ``pip``
|
||||
|
||||
Just run:
|
||||
|
||||
pip install maestro
|
||||
pip install island
|
||||
|
||||
Install pip on debian/ubuntu:
|
||||
|
||||
@@ -61,11 +67,50 @@ Install pip on MacOs:
|
||||
|
||||
sudo easy_install pip
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Select a manifest:
|
||||
|
||||
island init http://github.com/atria-soft/manifest.git
|
||||
|
||||
Download and synchronize the sources:
|
||||
|
||||
island sync
|
||||
|
||||
Select all branch availlable in the worktree: (checkout origin/dev in dev branch and track it, do nothing if the branch does not exist)
|
||||
|
||||
island checkout dev
|
||||
|
||||
Show the status of the workspace
|
||||
|
||||
island status
|
||||
|
||||
TODO list
|
||||
---------
|
||||
|
||||
- When sync checkout the new manifest
|
||||
- status: show how many time late we are on the branch
|
||||
- sync: filter the apply of this cmd
|
||||
- create snapshot
|
||||
- use a snapshot
|
||||
- commit all change in a single commit name and date
|
||||
- push all change in the origin branch
|
||||
- stash/unstash all change
|
||||
- permit to set the pasword when requested by git
|
||||
- sync: show download progress
|
||||
- support single project mirror
|
||||
- support submodule mirror
|
||||
- support project upstream
|
||||
- support submodule add upstream
|
||||
- push modilfication in all late mirorr (force mode optionnal) ==> for automatic server synchronisation in 4 lines
|
||||
- a good documation of the format and the usage
|
||||
- parallele download / sync / push ...
|
||||
|
||||
License (MPL v2.0)
|
||||
---------------------
|
||||
|
||||
Copyright maestro Edouard DUPIN
|
||||
Copyright island Edouard DUPIN
|
||||
|
||||
Licensed under the Mozilla Public License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
11
bin/island
Executable file
11
bin/island
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
|
||||
import island
|
196
bin/maestro
196
bin/maestro
@@ -1,196 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
|
||||
# for path inspection:
|
||||
import sys
|
||||
import os
|
||||
import copy
|
||||
import maestro
|
||||
import maestro.debug as debug
|
||||
import maestro.arg as arguments
|
||||
import maestro.host as host
|
||||
import maestro.env as env
|
||||
import maestro.tools as tools
|
||||
import maestro.host as maestroHost
|
||||
import maestro.tools as maestroTools
|
||||
|
||||
myArgs = arguments.maestroArg()
|
||||
myArgs.add_section("option", "Can be set one time in all case")
|
||||
myArgs.add("h", "help", desc="Display this help")
|
||||
myArgs.add("v", "verbose", list=[["0","None"],["1","error"],["2","warning"],["3","info"],["4","debug"],["5","verbose"],["6","extreme_verbose"]], desc="display debug level (verbose) default =2")
|
||||
myArgs.add("c", "color", desc="Display message in color")
|
||||
"""
|
||||
myArgs.add("j", "jobs", haveParam=True, desc="Specifies the number of jobs (commands) to run simultaneously")
|
||||
myArgs.add("d", "depth", haveParam=True, desc="Depth to clone all the repository")
|
||||
|
||||
"""
|
||||
localArgument = myArgs.parse()
|
||||
|
||||
|
||||
"""
|
||||
display the help of this makefile
|
||||
"""
|
||||
def usage():
|
||||
color = debug.get_color_set()
|
||||
# generic argument displayed :
|
||||
myArgs.display()
|
||||
print(" Action availlable" )
|
||||
print(" " + color['green'] + "init" + color['default'])
|
||||
print(" initialize a 'maestro' interface with a manifest in a git ")
|
||||
print(" " + color['green'] + "sync" + color['default'])
|
||||
print(" Syncronise the currect environement")
|
||||
print(" " + color['green'] + "status" + color['default'])
|
||||
print(" Dump the status of the environement")
|
||||
print(" ex: " + sys.argv[0] + " -c init http://github.com/atria-soft/manifest.git")
|
||||
print(" ex: " + sys.argv[0] + " sync")
|
||||
exit(0)
|
||||
|
||||
def check_boolean(value):
|
||||
if value == "" \
|
||||
or value == "1" \
|
||||
or value == "true" \
|
||||
or value == "True" \
|
||||
or value == True:
|
||||
return True
|
||||
return False
|
||||
|
||||
# preparse the argument to get the verbose element for debug mode
|
||||
def parseGenericArg(argument, active):
|
||||
debug.extreme_verbose("parse arg : " + argument.get_option_name() + " " + argument.get_arg() + " active=" + str(active))
|
||||
if argument.get_option_name() == "help":
|
||||
if active == False:
|
||||
usage()
|
||||
return True
|
||||
elif argument.get_option_name()=="jobs":
|
||||
if active == True:
|
||||
#multiprocess.set_core_number(int(argument.get_arg()))
|
||||
pass
|
||||
return True
|
||||
elif argument.get_option_name()=="depth":
|
||||
if active == True:
|
||||
env.set_parse_depth(int(argument.get_arg()))
|
||||
return True
|
||||
elif argument.get_option_name() == "verbose":
|
||||
if active == True:
|
||||
debug.set_level(int(argument.get_arg()))
|
||||
return True
|
||||
elif argument.get_option_name() == "color":
|
||||
if active == True:
|
||||
if check_boolean(argument.get_arg()) == True:
|
||||
debug.enable_color()
|
||||
else:
|
||||
debug.disable_color()
|
||||
return True
|
||||
return False
|
||||
|
||||
"""
|
||||
# open configuration of maestro:
|
||||
config_file_name = "maestroConfig.py"
|
||||
config_file = os.path.join(tools.get_run_path(), config_file_name)
|
||||
if os.path.isfile(config_file) == True:
|
||||
sys.path.append(os.path.dirname(config_file))
|
||||
debug.debug("Find basic configuration file: '" + config_file + "'")
|
||||
# the file exist, we can open it and get the initial configuration:
|
||||
configuration_file = __import__(config_file_name[:-3])
|
||||
|
||||
if "get_exclude_path" in dir(configuration_file):
|
||||
data = configuration_file.get_exclude_path()
|
||||
debug.debug(" get default config 'get_exclude_path' val='" + str(data) + "'")
|
||||
env.set_exclude_search_path(data)
|
||||
|
||||
if "get_parsing_depth" in dir(configuration_file):
|
||||
data = configuration_file.get_parsing_depth()
|
||||
debug.debug(" get default config 'get_parsing_depth' val='" + str(data) + "'")
|
||||
parseGenericArg(arguments.ArgElement("depth", str(data)), True)
|
||||
|
||||
if "get_default_jobs" in dir(configuration_file):
|
||||
data = configuration_file.get_default_jobs()
|
||||
debug.debug(" get default config 'get_default_jobs' val='" + str(data) + "'")
|
||||
parseGenericArg(arguments.ArgElement("jobs", str(data)), True)
|
||||
|
||||
if "get_default_color" in dir(configuration_file):
|
||||
data = configuration_file.get_default_color()
|
||||
debug.debug(" get default config 'get_default_color' val='" + str(data) + "'")
|
||||
parseGenericArg(arguments.ArgElement("color", str(data)), True)
|
||||
|
||||
if "get_default_debug_level" in dir(configuration_file):
|
||||
data = configuration_file.get_default_debug_level()
|
||||
debug.debug(" get default config 'get_default_debug_level' val='" + str(data) + "'")
|
||||
parseGenericArg(arguments.ArgElement("verbose", str(data)), True)
|
||||
|
||||
if "get_default_print_pretty" in dir(configuration_file):
|
||||
data = configuration_file.get_default_print_pretty()
|
||||
debug.debug(" get default config 'get_default_print_pretty' val='" + str(data) + "'")
|
||||
parseGenericArg(arguments.ArgElement("pretty", str(data)), True)
|
||||
|
||||
if "get_default_force_optimisation" in dir(configuration_file):
|
||||
data = configuration_file.get_default_force_optimisation()
|
||||
debug.debug(" get default config 'get_default_force_optimisation' val='" + str(data) + "'")
|
||||
parseGenericArg(arguments.ArgElement("force-optimisation", str(data)), True)
|
||||
|
||||
if "get_default_isolate_system" in dir(configuration_file):
|
||||
data = configuration_file.get_default_isolate_system()
|
||||
debug.debug(" get default config 'get_default_isolate_system' val='" + str(data) + "'")
|
||||
parseGenericArg(arguments.ArgElement("isolate-system", str(data)), True)
|
||||
|
||||
"""
|
||||
|
||||
# parse default unique argument:
|
||||
for argument in localArgument:
|
||||
parseGenericArg(argument, True)
|
||||
|
||||
# initialize the system ...
|
||||
maestro.init()
|
||||
|
||||
# remove all generic arguments:
|
||||
new_argument_list = []
|
||||
for argument in localArgument:
|
||||
if parseGenericArg(argument, False) == True:
|
||||
continue
|
||||
new_argument_list.append(argument)
|
||||
|
||||
# now the first argument is: the action:
|
||||
if len(new_argument_list) == 0:
|
||||
debug.warning("--------------------------------------")
|
||||
debug.warning("Missing the action to do ...")
|
||||
debug.warning("--------------------------------------")
|
||||
usage()
|
||||
|
||||
list_of_action_availlable=["init","sync","status"]
|
||||
|
||||
action_to_do = new_argument_list[0].get_arg()
|
||||
new_argument_list = new_argument_list[1:]
|
||||
if action_to_do not in list_of_action_availlable:
|
||||
debug.warning("--------------------------------------")
|
||||
debug.warning("Wrong action type : '" + str(action_to_do) + "' availlable list: " + str(list_of_action_availlable) )
|
||||
debug.warning("--------------------------------------")
|
||||
usage()
|
||||
|
||||
if action_to_do != "init" \
|
||||
and os.path.exists("." + env.get_system_base_name()) == False:
|
||||
debug.error("Can not execute a maestro cmd if we have not initialize a config: '" + str("." + env.get_system_base_name()) + "'")
|
||||
exit(-1)
|
||||
|
||||
if action_to_do == "init":
|
||||
debug.info("action: init");
|
||||
|
||||
elif action_to_do == "sync":
|
||||
debug.info("action: sync");
|
||||
|
||||
elif action_to_do == "status":
|
||||
debug.info("action: status");
|
||||
|
||||
else:
|
||||
debug.error("Can not do the action...")
|
||||
|
||||
# stop all started threads;
|
||||
#multiprocess.un_init()
|
||||
|
||||
|
241
island/__init__.py
Executable file
241
island/__init__.py
Executable file
@@ -0,0 +1,241 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
import os
|
||||
import sys
|
||||
import fnmatch
|
||||
import copy
|
||||
# Local import
|
||||
from . import host
|
||||
from . import tools
|
||||
from realog import debug
|
||||
from . import env
|
||||
from . import actions
|
||||
import death.Arguments as arguments
|
||||
import death.ArgElement as arg_element
|
||||
is_init = False
|
||||
|
||||
debug.set_display_on_error(" ==========================\n == Some error occured ==\n ==========================")
|
||||
|
||||
def filter_name_and_file(root, list_files, filter):
|
||||
# filter elements:
|
||||
tmp_list = fnmatch.filter(list_files, filter)
|
||||
out = []
|
||||
for elem in tmp_list:
|
||||
if os.path.isfile(os.path.join(root, elem)) == True:
|
||||
out.append(elem);
|
||||
return out;
|
||||
|
||||
def import_path_local(path):
|
||||
out = []
|
||||
debug.verbose("island files: " + str(path) + " [START]")
|
||||
list_files = os.listdir(path)
|
||||
# filter elements:
|
||||
tmp_list_island_file = filter_name_and_file(path, list_files, env.get_system_base_name() + "*.py")
|
||||
debug.verbose("island files: " + str(path) + " : " + str(tmp_list_island_file))
|
||||
# Import the module:
|
||||
for filename in tmp_list_island_file:
|
||||
out.append(os.path.join(path, filename))
|
||||
debug.verbose(" Find a file : '" + str(out[-1]) + "'")
|
||||
return out
|
||||
|
||||
|
||||
def init():
|
||||
global is_init;
|
||||
if is_init == True:
|
||||
return
|
||||
list_of_island_files = import_path_local(os.path.join(tools.get_current_path(__file__), 'actions'))
|
||||
|
||||
actions.init(list_of_island_files)
|
||||
|
||||
is_init = True
|
||||
|
||||
# initialize the system ...
|
||||
init()
|
||||
|
||||
|
||||
debug.verbose("List of actions: " + str(actions.get_list_of_action()))
|
||||
|
||||
my_args = arguments.Arguments()
|
||||
my_args.add_section("option", "Can be set one time in all case")
|
||||
my_args.add("h", "help", desc="Display this help")
|
||||
my_args.add("v", "verbose", list=[
|
||||
["0","None"],
|
||||
["1","error"],
|
||||
["2","warning"],
|
||||
["3","info"],
|
||||
["4","debug"],
|
||||
["5","verbose"],
|
||||
["6","extreme_verbose"],
|
||||
], desc="display debug level (verbose) default =2")
|
||||
my_args.add("c", "color", desc="Display message in color")
|
||||
my_args.add("n", "no-fetch-manifest", haveParam=False, desc="Disable the fetch of the manifest")
|
||||
my_args.add("F", "filter", haveParam=True, desc="Filter the action on a list of path or subpath: -f library")
|
||||
my_args.add("f", "folder", haveParam=False, desc="Display the folder instead of the git repository name")
|
||||
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()
|
||||
|
||||
##
|
||||
## @brief Display the help of this makefile.
|
||||
##
|
||||
def usage():
|
||||
color = debug.get_color_set()
|
||||
# generic argument displayed :
|
||||
my_args.display()
|
||||
print(" Action availlable" )
|
||||
list_actions = actions.get_list_of_action();
|
||||
for elem in list_actions:
|
||||
print(" " + color['green'] + elem + color['default'])
|
||||
print(" " + actions.get_action_help(elem))
|
||||
"""
|
||||
print(" " + color['green'] + "init" + color['default'])
|
||||
print(" initialize a 'island' interface with a manifest in a git ")
|
||||
print(" " + color['green'] + "sync" + color['default'])
|
||||
print(" Syncronise the currect environement")
|
||||
print(" " + color['green'] + "status" + color['default'])
|
||||
print(" Dump the status of the environement")
|
||||
"""
|
||||
print(" ex: " + sys.argv[0] + " -c init http://github.com/atria-soft/manifest.git")
|
||||
print(" ex: " + sys.argv[0] + " sync")
|
||||
exit(0)
|
||||
|
||||
def check_boolean(value):
|
||||
if value == "" \
|
||||
or value == "1" \
|
||||
or value == "true" \
|
||||
or value == "True" \
|
||||
or value == True:
|
||||
return True
|
||||
return False
|
||||
|
||||
# preparse the argument to get the verbose element for debug mode
|
||||
def parse_generic_arg(argument, active):
|
||||
debug.extreme_verbose("parse arg : " + argument.get_option_name() + " " + argument.get_arg() + " active=" + str(active))
|
||||
if argument.get_option_name() == "help":
|
||||
if active == False:
|
||||
usage()
|
||||
return True
|
||||
elif argument.get_option_name()=="jobs":
|
||||
if active == True:
|
||||
#multiprocess.set_core_number(int(argument.get_arg()))
|
||||
pass
|
||||
return True
|
||||
elif argument.get_option_name()=="wait":
|
||||
if active == True:
|
||||
env.set_wait_between_sever_command(int(argument.get_arg()))
|
||||
return True
|
||||
elif argument.get_option_name() == "verbose":
|
||||
if active == True:
|
||||
debug.set_level(int(argument.get_arg()))
|
||||
return True
|
||||
elif argument.get_option_name() == "folder":
|
||||
if active == True:
|
||||
env.set_display_folder_instead_of_git_name(True)
|
||||
return True
|
||||
elif argument.get_option_name() == "color":
|
||||
if active == True:
|
||||
if check_boolean(argument.get_arg()) == True:
|
||||
debug.enable_color()
|
||||
else:
|
||||
debug.disable_color()
|
||||
return True
|
||||
elif argument.get_option_name() == "filter":
|
||||
if active == True:
|
||||
env.set_filter_command(str(argument.get_arg()))
|
||||
return True
|
||||
elif argument.get_option_name() == "no-fetch-manifest":
|
||||
if active == False:
|
||||
env.set_fetch_manifest(False)
|
||||
return True
|
||||
return False
|
||||
|
||||
# open configuration of island:
|
||||
config_file = env.get_island_path_user_config()
|
||||
if os.path.isfile(config_file) == True:
|
||||
sys.path.append(os.path.dirname(config_file))
|
||||
debug.debug("Find basic configuration file: '" + config_file + "'")
|
||||
# the file exist, we can open it and get the initial configuration:
|
||||
configuration_file = __import__(env.get_system_config_name()[:-3])
|
||||
|
||||
if "get_exclude_path" in dir(configuration_file):
|
||||
data = configuration_file.get_exclude_path()
|
||||
debug.debug(" get default config 'get_exclude_path' val='" + str(data) + "'")
|
||||
env.set_exclude_search_path(data)
|
||||
|
||||
if "get_default_color" in dir(configuration_file):
|
||||
data = configuration_file.get_default_color()
|
||||
debug.debug(" get default config 'get_default_color' val='" + str(data) + "'")
|
||||
parse_generic_arg(arg_element.ArgElement("color", str(data)), True)
|
||||
|
||||
if "get_default_debug_level" in dir(configuration_file):
|
||||
data = configuration_file.get_default_debug_level()
|
||||
debug.debug(" get default config 'get_default_debug_level' val='" + str(data) + "'")
|
||||
parse_generic_arg(arg_element.ArgElement("verbose", str(data)), True)
|
||||
|
||||
if "get_default_folder" in dir(configuration_file):
|
||||
data = configuration_file.get_default_folder()
|
||||
debug.debug(" get default config 'get_default_folder' val='" + str(data) + "'")
|
||||
parse_generic_arg(arg_element.ArgElement("folder", str(data)), True)
|
||||
|
||||
if "get_default_wait" in dir(configuration_file):
|
||||
data = configuration_file.get_default_wait()
|
||||
debug.debug(" get default config 'get_default_wait' val='" + str(data) + "'")
|
||||
parse_generic_arg(arg_element.ArgElement("wait", str(data)), True)
|
||||
|
||||
if "get_default_filter" in dir(configuration_file):
|
||||
data = configuration_file.get_default_filter()
|
||||
debug.debug(" get default config 'get_default_filter' val='" + str(data) + "'")
|
||||
parse_generic_arg(arg_element.ArgElement("filter", str(data)), True)
|
||||
|
||||
|
||||
|
||||
# parse default unique argument:
|
||||
for argument in local_argument:
|
||||
parse_generic_arg(argument, True)
|
||||
|
||||
# remove all generic arguments:
|
||||
new_argument_list = []
|
||||
for argument in local_argument:
|
||||
if parse_generic_arg(argument, False) == True:
|
||||
continue
|
||||
new_argument_list.append(argument)
|
||||
|
||||
# now the first argument is: the action:
|
||||
if len(new_argument_list) == 0:
|
||||
debug.warning("--------------------------------------")
|
||||
debug.warning("Missing the action to do ...")
|
||||
debug.warning("--------------------------------------")
|
||||
usage()
|
||||
|
||||
|
||||
# TODO : move tin in actions ...
|
||||
list_actions = actions.get_list_of_action();
|
||||
|
||||
action_to_do = new_argument_list[0].get_arg()
|
||||
new_argument_list = new_argument_list[1:]
|
||||
if action_to_do not in list_actions:
|
||||
debug.warning("--------------------------------------")
|
||||
debug.warning("Wrong action type : '" + str(action_to_do) + "' availlable list: " + str(list_actions) )
|
||||
debug.warning("--------------------------------------")
|
||||
usage()
|
||||
|
||||
# todo : Remove this
|
||||
if action_to_do != "init" \
|
||||
and os.path.exists(env.get_island_path()) == False:
|
||||
debug.error("Can not execute a island cmd if we have not initialize a config: '" + str("." + env.get_system_base_name()) + "' in upper 6 parent path")
|
||||
exit(-1)
|
||||
|
||||
|
||||
actions.execute(action_to_do, my_args.get_last_parsed()+1)
|
||||
|
||||
# stop all started threads;
|
||||
#multiprocess.un_init()
|
||||
|
||||
|
138
island/actions.py
Normal file
138
island/actions.py
Normal file
@@ -0,0 +1,138 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
|
||||
# Local import
|
||||
from realog import debug
|
||||
import os
|
||||
import sys
|
||||
from . import env
|
||||
import death.Arguments as arguments
|
||||
|
||||
list_actions = []
|
||||
|
||||
__base_action_name = env.get_system_base_name() + "Action_"
|
||||
|
||||
def init(files):
|
||||
global list_actions;
|
||||
debug.debug("List of action for island: ")
|
||||
for elem_path in files :
|
||||
base_name = os.path.basename(elem_path)
|
||||
if len(base_name) <= 3 + len(__base_action_name):
|
||||
# reject it, too small
|
||||
continue
|
||||
base_name = base_name[:-3]
|
||||
if base_name[:len(__base_action_name)] != __base_action_name:
|
||||
# reject it, wrong start file
|
||||
continue
|
||||
name_action = base_name[len(__base_action_name):]
|
||||
debug.debug(" '" + os.path.basename(elem_path)[:-3] + "' file=" + elem_path)
|
||||
list_actions.append({
|
||||
"name":name_action,
|
||||
"path":elem_path,
|
||||
})
|
||||
|
||||
##
|
||||
## @brief Get the wall list of action availlable
|
||||
## @return ([string]) the list of action name
|
||||
##
|
||||
def get_list_of_action():
|
||||
global list_actions;
|
||||
out = []
|
||||
for elem in list_actions:
|
||||
out.append(elem["name"])
|
||||
return out
|
||||
|
||||
##
|
||||
## @brief Get a description of an action
|
||||
## @param[in] action_name (string) Name of the action
|
||||
## @param[in] function_name (string) Name of the fucntion to call
|
||||
## @param[in] default_value (*) Renurned value of the call if function does not exist
|
||||
## @return (*) the getted value or the default_value
|
||||
##
|
||||
def get_function_value(action_name, function_name, default_value = None):
|
||||
global list_actions;
|
||||
for elem in list_actions:
|
||||
if elem["name"] == action_name:
|
||||
# finish the parsing
|
||||
sys.path.append(os.path.dirname(elem["path"]))
|
||||
the_action = __import__(__base_action_name + action_name)
|
||||
if function_name not in dir(the_action):
|
||||
return default_value
|
||||
method_to_call = getattr(the_action, function_name)
|
||||
return method_to_call()
|
||||
return default_value
|
||||
|
||||
##
|
||||
## @brief Get the global help value of a module
|
||||
## @param[in] action_name (string) Name of the action
|
||||
## @return The first line of description
|
||||
##
|
||||
def get_action_help(action_name):
|
||||
value = get_function_value(action_name, "help", "---")
|
||||
return value.split("\n")[0]
|
||||
|
||||
|
||||
def usage(arguments, action_name):
|
||||
color = debug.get_color_set()
|
||||
# generic argument displayed for specific action:
|
||||
#print("Specific argument for the command: '" + action_name + "'" )
|
||||
#print(" " + get_desc(action_name))
|
||||
value = get_function_value(action_name, "help")
|
||||
debug.info("Description:")
|
||||
debug.info("\t" + str(value))
|
||||
arguments.display(action_name)
|
||||
value = get_function_value(action_name, "help_example")
|
||||
if value != None:
|
||||
debug.info("Example:")
|
||||
for elem in value.split("\n"):
|
||||
debug.info("\t" + value)
|
||||
exit(0)
|
||||
|
||||
def execute(action_name, argument_start_id):
|
||||
global list_actions;
|
||||
# TODO: Move here the check if action is availlable
|
||||
|
||||
for elem in list_actions:
|
||||
if elem["name"] != action_name:
|
||||
continue
|
||||
debug.info("action: " + str(elem));
|
||||
# finish the parsing
|
||||
sys.path.append(os.path.dirname(elem["path"]))
|
||||
the_action = __import__(__base_action_name + action_name)
|
||||
my_under_args_parser = arguments.Arguments()
|
||||
my_under_args_parser.add("h", "help", desc="Help of this action")
|
||||
|
||||
if "add_specific_arguments" in dir(the_action):
|
||||
the_action.add_specific_arguments(my_under_args_parser, elem["name"])
|
||||
have_unknow_argument = False
|
||||
if "have_unknow_argument" in dir(the_action):
|
||||
have_unknow_argument = the_action.have_unknow_argument()
|
||||
my_under_args = my_under_args_parser.parse(argument_start_id, have_unknow_argument)
|
||||
# search help if needed ==> permit to not duplicating code
|
||||
for elem in my_under_args:
|
||||
if elem.get_option_name() == "help":
|
||||
usage(my_under_args_parser, action_name)
|
||||
return 0
|
||||
# now we can execute:
|
||||
if "execute" not in dir(the_action):
|
||||
debug.error("execute is not implmented for this action ... '" + str(action_name) + "'")
|
||||
return -11
|
||||
debug.info("execute: " + action_name)
|
||||
for elem in my_under_args:
|
||||
debug.debug(" " + str(elem.get_option_name()) + "='" + str(elem.get_arg()) + "'")
|
||||
ret = the_action.execute(my_under_args)
|
||||
if ret == None:
|
||||
return 0
|
||||
debug.info(" ==========================")
|
||||
debug.info(" == Some error occured ==")
|
||||
debug.info(" ==========================")
|
||||
return ret
|
||||
debug.error("Can not do the action...")
|
||||
return -10
|
137
island/actions/islandAction_checkout.py
Normal file
137
island/actions/islandAction_checkout.py
Normal file
@@ -0,0 +1,137 @@
|
||||
#!/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 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)
|
||||
##
|
||||
def 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
|
||||
##
|
||||
def add_specific_arguments(my_args, section):
|
||||
my_args.add("r", "remote", haveParam=True, desc="Name of the remote server")
|
||||
my_args.add_arg("branch", optionnal=False, desc="Branch to checkout")
|
||||
|
||||
##
|
||||
## @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
|
||||
##
|
||||
def 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.Config()
|
||||
|
||||
# update the local configuration file:
|
||||
configuration.set_branch(branch_to_checkout)
|
||||
configuration.store()
|
||||
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == False:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
|
||||
all_project = mani.get_all_configs()
|
||||
debug.info("checkout of: " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
debug.verbose("checkout : " + base_display)
|
||||
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == False:
|
||||
debug.warning("checkout " + base_display + " ==> repository does not exist ...")
|
||||
continue
|
||||
|
||||
# check if the repository is modify
|
||||
is_modify = commands.check_repository_is_modify(git_repo_path)
|
||||
if is_modify == True:
|
||||
debug.warning("checkout " + base_display + " ==> modify data can not checkout new branch")
|
||||
continue
|
||||
|
||||
list_branch_local = commands.get_list_branch_local(git_repo_path)
|
||||
select_branch = commands.get_current_branch(git_repo_path)
|
||||
|
||||
# check if we are on the good branch:
|
||||
if branch_to_checkout == select_branch:
|
||||
debug.info("checkout " + base_display + " ==> No change already on good branch")
|
||||
continue
|
||||
|
||||
# check if we have already checkout the branch before
|
||||
debug.verbose(" check : " + branch_to_checkout + " in " + str(list_branch_local))
|
||||
if branch_to_checkout in list_branch_local:
|
||||
cmd = "git checkout " + branch_to_checkout
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||
if ret[0] != 0 \
|
||||
and ret[1] != "" \
|
||||
and ret != False:
|
||||
debug.info("'" + str(ret) + "'")
|
||||
debug.error("checkout " + base_display + " ==> Can not checkout to the correct branch")
|
||||
continue
|
||||
debug.info("checkout " + base_display + " ==> switch branch")
|
||||
# TODO : Check the number of commit to the origin/XXX branch ....
|
||||
continue
|
||||
|
||||
# Check if the remote branch exist ...
|
||||
list_branch_remote = commands.get_list_branch_remote(git_repo_path)
|
||||
if elem.select_remote["name"] + "/" + branch_to_checkout in list_branch_remote:
|
||||
debug.info(" ==> find ...")
|
||||
else:
|
||||
debug.info("checkout " + base_display + " ==> NO remote branch")
|
||||
continue
|
||||
|
||||
# checkout the new branch:
|
||||
cmd = "git checkout --quiet " + elem.select_remote["name"] + "/" + branch_to_checkout + " -b " + branch_to_checkout
|
||||
# + " --track " + elem.select_remote["name"] + "/" + branch_to_checkout
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||
if ret[1] != "" \
|
||||
and ret != False:
|
||||
debug.info("'" + str(ret) + "'")
|
||||
debug.error("checkout " + base_display + " ==> Can not checkout to the correct branch")
|
||||
continue
|
||||
debug.info("checkout " + base_display + " ==> create new branch")
|
||||
continue
|
||||
|
||||
|
||||
|
83
island/actions/islandAction_command.py
Normal file
83
island/actions/islandAction_command.py
Normal file
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
|
||||
from realog import debug
|
||||
from island import tools
|
||||
from island import env
|
||||
from island import multiprocess
|
||||
from island import config
|
||||
from island import manifest
|
||||
from island import commands
|
||||
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)
|
||||
##
|
||||
def help():
|
||||
return "Write the command you want to be executed in every repository"
|
||||
|
||||
##
|
||||
## @brief Set the option argument are not able to check if the argument are correct or not
|
||||
## @return (boolean) have parameter without arguments
|
||||
##
|
||||
def have_unknow_argument():
|
||||
return True
|
||||
|
||||
##
|
||||
## @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
|
||||
##
|
||||
def execute(_arguments):
|
||||
cmd = ""
|
||||
for elem in _arguments:
|
||||
debug.info("Get data element: " + str(elem.get_arg()))
|
||||
cmd += elem.get_arg() + " "
|
||||
|
||||
# check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
|
||||
configuration = config.Config()
|
||||
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == False:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
|
||||
all_project = mani.get_all_configs()
|
||||
debug.info("status of: " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
for elem in all_project:
|
||||
debug.info("------------------------------------------")
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
debug.info("execute command : " + base_display)
|
||||
tools.wait_for_server_if_needed()
|
||||
#debug.debug("elem : " + str(elem))
|
||||
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == False:
|
||||
debug.info("" + base_display + "\r\t\t\t\t\t\t\t\t\t" + " (not download)")
|
||||
continue
|
||||
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||
if ret[0] == 0:
|
||||
debug.info("ret=" + ret[1])
|
||||
debug.info("err=" + ret[2])
|
||||
else:
|
||||
debug.info("Execution ERROR")
|
||||
|
95
island/actions/islandAction_commit.py
Normal file
95
island/actions/islandAction_commit.py
Normal file
@@ -0,0 +1,95 @@
|
||||
#!/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 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)
|
||||
##
|
||||
def help():
|
||||
return "Commit 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
|
||||
##
|
||||
def add_specific_arguments(my_args, section):
|
||||
my_args.add("m", "message", haveParam=True, desc="Message to commit data")
|
||||
my_args.add("a", "all", desc="Commit all elements")
|
||||
my_args.add("", "amend", desc="Ammend data at the previous commit")
|
||||
|
||||
##
|
||||
## @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
|
||||
##
|
||||
def execute(_arguments):
|
||||
argument_message = ""
|
||||
argument_amend = ""
|
||||
argument_all = ""
|
||||
for elem in _arguments:
|
||||
if elem.get_option_name() == "message":
|
||||
debug.info("find message: '" + elem.get_arg() + "'")
|
||||
argument_message = " --message \"" + elem.get_arg() + "\" ";
|
||||
elif elem.get_option_name() == "all":
|
||||
argument_all = " --all "
|
||||
elif elem.get_option_name() == "amend":
|
||||
argument_amend = " --amend "
|
||||
else:
|
||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||
|
||||
# check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
|
||||
configuration = config.Config()
|
||||
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == False:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
|
||||
all_project = mani.get_all_configs()
|
||||
debug.info("commit : " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
debug.info("commit: " + base_display)
|
||||
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == False:
|
||||
debug.error("can not commit project that not exist")
|
||||
continue
|
||||
|
||||
if os.path.exists(os.path.join(git_repo_path,".git")) == False:
|
||||
# path already exist but it is not used to as a git repo ==> this is an error
|
||||
debug.warning("path '" + git_repo_path + "' is already existing but not used for a git repository. Clean it and restart")
|
||||
continue;
|
||||
|
||||
# simply update the repository ...
|
||||
debug.verbose("commit in project:")
|
||||
# fetch the repository
|
||||
cmd = "git commit " + argument_amend + argument_all + argument_message
|
||||
debug.debug("execute : " + cmd)
|
||||
multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||
|
136
island/actions/islandAction_deliver-push.py
Normal file
136
island/actions/islandAction_deliver-push.py
Normal file
@@ -0,0 +1,136 @@
|
||||
#!/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 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)
|
||||
##
|
||||
def help():
|
||||
return "Push a delover (develop & master & tag) on the remotre server"
|
||||
|
||||
##
|
||||
## @brief Add argument to the specific action
|
||||
## @param[in,out] my_args (death.Arguments) Argument manager
|
||||
## @param[in] section Name of the currect action
|
||||
##
|
||||
def add_specific_arguments(my_args, section):
|
||||
my_args.add("r", "remote", haveParam=True, desc="Name of the remote server")
|
||||
|
||||
##
|
||||
## @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
|
||||
##
|
||||
def execute(_arguments):
|
||||
argument_remote_name = ""
|
||||
for elem in _arguments:
|
||||
if elem.get_option_name() == "remote":
|
||||
debug.info("find remote name: '" + elem.get_arg() + "'")
|
||||
argument_remote_name = elem.get_arg()
|
||||
else:
|
||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||
|
||||
# check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
|
||||
|
||||
configuration = config.Config()
|
||||
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == False:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
|
||||
all_project = mani.get_all_configs()
|
||||
debug.info("fetch : " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
|
||||
# configure remote name:
|
||||
if argument_remote_name == "":
|
||||
argument_remote_name = elem.select_remote["name"]
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
debug.info("deliver-push: " + base_display)
|
||||
tools.wait_for_server_if_needed()
|
||||
# Check the repo exist
|
||||
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == False:
|
||||
debug.warning("deliver-push: " + base_display + " ==> MUST be download")
|
||||
continue
|
||||
# check if we are on "master"
|
||||
select_branch = commands.get_current_branch(git_repo_path)
|
||||
if select_branch != "master":
|
||||
debug.warning("deliver-push: " + base_display + " ==> MUST be on master")
|
||||
continue
|
||||
# check if we have a local branch
|
||||
list_branch_local = commands.get_list_branch_local(git_repo_path)
|
||||
if "develop" not in list_branch_local:
|
||||
debug.warning("deliver-push: " + base_display + " ==> No 'develop' (not managed)")
|
||||
continue
|
||||
if "master" not in list_branch_local:
|
||||
debug.warning("deliver-push: " + base_display + " ==> No 'master' (not managed)")
|
||||
continue
|
||||
list_of_element_to_push = []
|
||||
# check sha1 of master
|
||||
sha_1_master = commands.get_sha1_for_branch(git_repo_path, "master")
|
||||
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, "master")
|
||||
if tracking_remote_branch == None:
|
||||
debug.warning("deliver-push: " + base_display + " ==> 'master' have no tracking branch")
|
||||
deliver_availlable = False
|
||||
sha_1_master_tracking = commands.get_sha1_for_branch(git_repo_path, tracking_remote_branch)
|
||||
if sha_1_master == sha_1_master_tracking:
|
||||
debug.info("deliver-push: " + base_display + " ==> 'master' && '" + tracking_remote_branch + "' have the same sha1")
|
||||
else:
|
||||
list_of_element_to_push.append("master")
|
||||
# check sha1 of develop
|
||||
sha_1_develop = commands.get_sha1_for_branch(git_repo_path, "develop")
|
||||
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, "develop")
|
||||
if tracking_remote_branch == None:
|
||||
debug.info("deliver-push: " + base_display + " ==> 'develop' have no tracking branch")
|
||||
deliver_availlable = False
|
||||
sha_1_develop_tracking = commands.get_sha1_for_branch(git_repo_path, tracking_remote_branch)
|
||||
if sha_1_develop == sha_1_develop_tracking:
|
||||
debug.info("deliver-push: " + base_display + " ==> 'develop' && '" + tracking_remote_branch + "' have the same sha1")
|
||||
else:
|
||||
list_of_element_to_push.append("develop")
|
||||
ret_current_tags = commands.get_tags_current(git_repo_path)
|
||||
if len(ret_current_tags) == 0:
|
||||
debug.info("deliver-push: " + base_display + " ==> No tag on the current 'master'")
|
||||
continue
|
||||
if len(ret_current_tags) > 1:
|
||||
debug.info("deliver-push: " + base_display + " ==> Too mush tags on the current 'master' : " + str(ret_current_tags) + " ==> only support 1")
|
||||
continue
|
||||
list_remote_tags = commands.get_tags_remote(git_repo_path, argument_remote_name)
|
||||
debug.verbose("remote tags: " + str(list_remote_tags))
|
||||
if ret_current_tags[0] not in list_remote_tags:
|
||||
debug.info("deliver-push: " + base_display + " ==> tag already exist.")
|
||||
list_of_element_to_push.append(ret_current_tags[0])
|
||||
if len(list_of_element_to_push) == 0:
|
||||
debug.info("deliver-push: " + base_display + " ==> Everything up-to-date")
|
||||
continue
|
||||
debug.info("deliver-push: " + base_display + " ==> element to push:" + str(list_of_element_to_push))
|
||||
#push all on the server:
|
||||
commands.push(git_repo_path, argument_remote_name, list_of_element_to_push)
|
||||
|
||||
|
222
island/actions/islandAction_deliver.py
Normal file
222
island/actions/islandAction_deliver.py
Normal file
@@ -0,0 +1,222 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
|
||||
from realog import debug
|
||||
from island import tools
|
||||
from island import env
|
||||
from island import multiprocess
|
||||
from island import config
|
||||
from island import manifest
|
||||
from island import commands
|
||||
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)
|
||||
##
|
||||
def help():
|
||||
return "Deliver the current repository (develop & master MUST be up to date and you MUST be on master)"
|
||||
|
||||
##
|
||||
## @brief Add argument to the specific action
|
||||
## @param[in,out] my_args (death.Arguments) Argument manager
|
||||
## @param[in] section Name of the currect action
|
||||
##
|
||||
def add_specific_arguments(_my_args, _section):
|
||||
pass
|
||||
|
||||
default_behind_message = "[DEV] update dev tag version"
|
||||
default_update_message = "[VERSION] update dev tag version"
|
||||
|
||||
##
|
||||
## @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
|
||||
##
|
||||
def execute(_arguments):
|
||||
argument_remote_name = ""
|
||||
for elem in _arguments:
|
||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||
|
||||
# check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
|
||||
configuration = config.Config()
|
||||
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == False:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
|
||||
all_project = mani.get_all_configs()
|
||||
debug.info("Check if all project are on master: " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
deliver_availlable = True
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
debug.verbose("deliver-ckeck: " + base_display)
|
||||
# Check the repo exist
|
||||
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == False:
|
||||
debug.warning("deliver-ckeck: " + base_display + " ==> MUST be download")
|
||||
deliver_availlable = False
|
||||
continue
|
||||
# check if we are on "master"
|
||||
select_branch = commands.get_current_branch(git_repo_path)
|
||||
if select_branch != "master":
|
||||
debug.warning("deliver-ckeck: " + base_display + " ==> MUST be on master")
|
||||
deliver_availlable = False
|
||||
# check if we have a remote traking branch
|
||||
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, select_branch)
|
||||
if tracking_remote_branch == None:
|
||||
debug.warning("deliver-ckeck: " + base_display + " ==> MUST have a remote tracking branch")
|
||||
deliver_availlable = False
|
||||
# check if we have a local branch
|
||||
list_branch_local = commands.get_list_branch_local(git_repo_path)
|
||||
if "develop" not in list_branch_local:
|
||||
debug.warning("deliver-ckeck: " + base_display + " ==> MUST have local branch named develop")
|
||||
deliver_availlable = False
|
||||
# TODO: check develop is up to date
|
||||
|
||||
# check if the curent repo is modify
|
||||
is_modify = commands.check_repository_is_modify(git_repo_path)
|
||||
if is_modify == True:
|
||||
debug.warning("deliver-ckeck: " + base_display + " ==> MUST not be modify")
|
||||
deliver_availlable = False
|
||||
# check the remote branch and the local branch are the same
|
||||
#sha_tracking = get_sha1_for_branch(git_repo_path, tracking_remote_branch)
|
||||
#sha_current = get_sha1_for_branch(git_repo_path, select_branch)
|
||||
if deliver_availlable == False:
|
||||
debug.error("deliver-ckeck: Correct the warning to validate the Merge")
|
||||
return
|
||||
debug.info("deliver-ckeck: ==> All is OK")
|
||||
id_element = 0
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
debug.info("deliver: ========================================================================")
|
||||
debug.info("deliver: == " + base_display)
|
||||
debug.info("deliver: ========================================================================")
|
||||
|
||||
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||
version_path_file = os.path.join(git_repo_path, "version.txt")
|
||||
add_in_version_management = False
|
||||
if os.path.exists(version_path_file) == False:
|
||||
debug.info("deliver: ==> No 'version.txt' file ==> not manage release version....")
|
||||
# Action to do:
|
||||
valid = False
|
||||
while valid == False:
|
||||
debug.info("Create a new version: (0.0.0)")
|
||||
debug.info(" (1) Add in managing version")
|
||||
debug.info(" (2) Do NOTHING & continue")
|
||||
input1 = input()
|
||||
if input1 in ["1", "2"]:
|
||||
valid = True
|
||||
else:
|
||||
debug.info("!!! Must select in range " + str(["1", "2"]))
|
||||
if input1 == "1":
|
||||
version_description = [0, 0, 0]
|
||||
add_in_version_management = True
|
||||
elif input1 == "2":
|
||||
debug.info("Continue Not managing for this repository")
|
||||
continue
|
||||
else:
|
||||
debug.warning("An error occured for this repository")
|
||||
continue
|
||||
else:
|
||||
version_description = tools.version_string_to_list(tools.file_read_data(version_path_file))
|
||||
debug.info("deliver: ==> version: " + str(version_description))
|
||||
|
||||
select_branch = commands.get_current_branch(git_repo_path)
|
||||
|
||||
# get tracking 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, "develop")
|
||||
# remove all identical sha1 ==> not needed for this
|
||||
have_forward = False
|
||||
for elem_sha1 in ret_current_branch_sha1:
|
||||
if elem_sha1 not in ret_track_branch_sha1:
|
||||
message = commands.get_specific_commit_message(git_repo_path, elem_sha1)
|
||||
debug.warning("deliver: Forward commit: '" + message + "'")
|
||||
have_forward = True
|
||||
if have_forward == True:
|
||||
debug.error("Master must not be forward develop branch")
|
||||
continue
|
||||
behind_message = ""
|
||||
behind_count = 0
|
||||
for elem_sha1 in ret_track_branch_sha1:
|
||||
if elem_sha1 not in ret_current_branch_sha1:
|
||||
message = commands.get_specific_commit_message(git_repo_path, elem_sha1)
|
||||
behind_count += 1
|
||||
behind_message = message
|
||||
if behind_count == 0 and add_in_version_management == False:
|
||||
debug.info("deliver: ==> Nothing to do (1).")
|
||||
continue
|
||||
if behind_count == 1 \
|
||||
and ( behind_message == default_behind_message
|
||||
or behind_message == default_update_message):
|
||||
debug.info("deliver: ==> Nothing to do (2).")
|
||||
continue
|
||||
for elem_sha1 in ret_track_branch_sha1:
|
||||
if elem_sha1 not in ret_current_branch_sha1:
|
||||
message = commands.get_specific_commit_message(git_repo_path, elem_sha1)
|
||||
debug.info("deliver: Behind commit: '" + message + "'")
|
||||
# Choice of the new version:
|
||||
valid = False
|
||||
while valid == False:
|
||||
debug.info("update version: curent: " + str(version_description))
|
||||
debug.info(" (1) Major version (change API)")
|
||||
debug.info(" (2) Medium version (add feature)")
|
||||
debug.info(" (3) Minor version (Bug fix & doc)")
|
||||
debug.info(" (4) Do not release & continue")
|
||||
input1 = input()
|
||||
if input1 in ["1", "2", "3", "4"]:
|
||||
valid = True
|
||||
else:
|
||||
debug.info("!!! Must select in range " + str(["1", "2", "3", "4"]))
|
||||
if input1 == "1":
|
||||
version_description[0] += 1
|
||||
version_description[1] = 0
|
||||
version_description[2] = 0
|
||||
elif input1 == "2":
|
||||
version_description[1] += 1
|
||||
version_description[2] = 0
|
||||
elif input1 == "3":
|
||||
version_description[2] += 1
|
||||
elif input1 == "4":
|
||||
debug.info("No release for this repository")
|
||||
continue
|
||||
else:
|
||||
debug.warning("An error occured for this repository")
|
||||
continue
|
||||
debug.info("new version: " + str(version_description))
|
||||
|
||||
commands.merge_branch_on_master(git_repo_path, "develop")
|
||||
|
||||
# update version file:
|
||||
tools.file_write_data(version_path_file, tools.version_to_string(version_description))
|
||||
commands.add_file(git_repo_path, version_path_file)
|
||||
commands.commit_all(git_repo_path, "[RELEASE] Release v" + tools.version_to_string(version_description))
|
||||
commands.tag(git_repo_path, "v" + tools.version_to_string(version_description))
|
||||
commands.checkout(git_repo_path, "develop")
|
||||
commands.reset_hard(git_repo_path, "master")
|
||||
version_description.append("dev")
|
||||
tools.file_write_data(version_path_file, tools.version_to_string(version_description))
|
||||
commands.add_file(git_repo_path, version_path_file)
|
||||
commands.commit_all(git_repo_path, default_update_message)
|
||||
commands.checkout(git_repo_path, "master")
|
||||
|
92
island/actions/islandAction_fetch.py
Normal file
92
island/actions/islandAction_fetch.py
Normal file
@@ -0,0 +1,92 @@
|
||||
#!/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 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)
|
||||
##
|
||||
def help():
|
||||
return "Fecth all the repository (get all modification on the server)"
|
||||
|
||||
##
|
||||
## @brief Add argument to the specific action
|
||||
## @param[in,out] my_args (death.Arguments) Argument manager
|
||||
## @param[in] section Name of the currect action
|
||||
##
|
||||
def add_specific_arguments(my_args, section):
|
||||
my_args.add("r", "remote", haveParam=True, desc="Name of the remote server")
|
||||
|
||||
##
|
||||
## @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
|
||||
##
|
||||
def execute(_arguments):
|
||||
argument_remote_name = ""
|
||||
for elem in _arguments:
|
||||
if elem.get_option_name() == "remote":
|
||||
debug.info("find remote name: '" + elem.get_arg() + "'")
|
||||
argument_remote_name = elem.get_arg()
|
||||
else:
|
||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||
|
||||
# check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
|
||||
debug.info("fetch manifest : '" + str(env.get_island_path_manifest()) + "'")
|
||||
commands.fetch(env.get_island_path_manifest(), "origin")
|
||||
|
||||
configuration = config.Config()
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == False:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
|
||||
all_project = mani.get_all_configs()
|
||||
debug.info("fetch : " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
# configure remote name:
|
||||
if argument_remote_name == "":
|
||||
argument_remote_name = elem.select_remote["name"]
|
||||
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
debug.info("fetch: " + base_display)
|
||||
tools.wait_for_server_if_needed()
|
||||
#debug.debug("elem : " + str(elem))
|
||||
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == False:
|
||||
debug.error("can not fetch project that not exist")
|
||||
continue
|
||||
|
||||
if os.path.exists(os.path.join(git_repo_path,".git")) == False:
|
||||
# path already exist but it is not used to as a git repo ==> this is an error
|
||||
debug.error("path '" + git_repo_path + "' is already existing but not used for a git repository. Clean it and restart")
|
||||
|
||||
# simply update the repository ...
|
||||
debug.verbose("Fetching project: ")
|
||||
|
||||
commands.fetch(git_repo_path, argument_remote_name)
|
||||
|
100
island/actions/islandAction_init.py
Normal file
100
island/actions/islandAction_init.py
Normal file
@@ -0,0 +1,100 @@
|
||||
#!/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 commands
|
||||
from island import multiprocess
|
||||
from island import manifest
|
||||
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)
|
||||
##
|
||||
def help():
|
||||
return "Init a island repository (need 'fetch' after)"
|
||||
|
||||
##
|
||||
## @brief Add argument to the specific action
|
||||
## @param[in,out] my_args (death.Arguments) Argument manager
|
||||
## @param[in] section Name of the currect action
|
||||
##
|
||||
def add_specific_arguments(my_args, section):
|
||||
my_args.add("b", "branch", haveParam=True, desc="Select branch to display")
|
||||
my_args.add("m", "manifest", haveParam=True, desc="Name of the manifest")
|
||||
|
||||
##
|
||||
## @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
|
||||
##
|
||||
def execute(_arguments):
|
||||
if len(_arguments) == 0:
|
||||
debug.error("Missing argument to execute the current action ...")
|
||||
|
||||
# the configuration availlable:
|
||||
branch = "master"
|
||||
manifest_name = "default.xml"
|
||||
address_manifest = ""
|
||||
for elem in _arguments:
|
||||
if elem.get_option_name() == "branch":
|
||||
debug.info("find branch name: '" + elem.get_arg() + "'")
|
||||
branch = elem.get_arg()
|
||||
elif elem.get_option_name() == "manifest":
|
||||
debug.info("find mmanifest name: '" + elem.get_arg() + "'")
|
||||
manifest_name = elem.get_arg()
|
||||
elif elem.get_option_name() == "":
|
||||
if address_manifest != "":
|
||||
debug.error("Manifest adress already set : '" + address_manifest + "' !!! '" + elem.get_arg() + "'")
|
||||
address_manifest = elem.get_arg()
|
||||
else:
|
||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||
|
||||
if address_manifest == "":
|
||||
debug.error("Init: Missing manifest name")
|
||||
|
||||
debug.info("Init with: '" + address_manifest + "' branch='" + branch + "' name of manifest='" + manifest_name + "'")
|
||||
|
||||
|
||||
# check if .XXX exist (create it if needed)
|
||||
if manifest.is_lutin_init() == True:
|
||||
debug.error("System already init: path already exist: '" + str(env.get_island_path()) + "'")
|
||||
|
||||
tools.create_directory(env.get_island_path())
|
||||
# check if the git of the manifest if availlable
|
||||
|
||||
# create the file configuration:
|
||||
conf = config.Config()
|
||||
conf.set_manifest(address_manifest)
|
||||
conf.set_branch(branch)
|
||||
conf.set_manifest_name(manifest_name)
|
||||
conf.store()
|
||||
|
||||
debug.info("Clone the manifest")
|
||||
ret_values = commands.clone(env.get_island_path_manifest(), address_manifest, branch_name=branch)
|
||||
|
||||
if ret_values == False:
|
||||
debug.info("'" + str(ret_values) + "'")
|
||||
debug.error("Init does not work")
|
||||
return False
|
||||
|
||||
debug.info("Init done correctly ...")
|
||||
|
||||
return None
|
||||
|
||||
|
||||
|
60
island/actions/islandAction_manifest-sync.py
Normal file
60
island/actions/islandAction_manifest-sync.py
Normal file
@@ -0,0 +1,60 @@
|
||||
#!/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 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)
|
||||
##
|
||||
def help():
|
||||
return "Syncronize all the repository referenced"
|
||||
|
||||
##
|
||||
## @brief Add argument to the specific action
|
||||
## @param[in,out] my_args (death.Arguments) Argument manager
|
||||
## @param[in] section Name of the currect action
|
||||
##
|
||||
def add_specific_arguments(my_args, section):
|
||||
pass
|
||||
|
||||
##
|
||||
## @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
|
||||
##
|
||||
def execute(_arguments):
|
||||
for elem in _arguments:
|
||||
debug.error("pull Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||
|
||||
# check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
|
||||
configuration = config.Config()
|
||||
|
||||
debug.info("update manifest : '" + str(env.get_island_path_manifest()) + "'")
|
||||
is_modify_manifest = commands.check_repository_is_modify(env.get_island_path_manifest())
|
||||
if is_modify_manifest == True:
|
||||
commands.fetch(env.get_island_path_manifest(), "origin")
|
||||
else:
|
||||
commands.pull(env.get_island_path_manifest(), "origin")
|
||||
|
114
island/actions/islandAction_push.py
Normal file
114
island/actions/islandAction_push.py
Normal file
@@ -0,0 +1,114 @@
|
||||
#!/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 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)
|
||||
##
|
||||
def help():
|
||||
return "Push all repository to the upper server"
|
||||
|
||||
##
|
||||
## @brief Add argument to the specific action
|
||||
## @param[in,out] my_args (death.Arguments) Argument manager
|
||||
## @param[in] section Name of the currect action
|
||||
##
|
||||
def add_specific_arguments(my_args, section):
|
||||
my_args.add("r", "remote", haveParam=True, desc="Name of the remote server")
|
||||
|
||||
##
|
||||
## @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
|
||||
##
|
||||
def execute(_arguments):
|
||||
argument_remote_name = ""
|
||||
for elem in _arguments:
|
||||
if elem.get_option_name() == "remote":
|
||||
debug.info("find remote name: '" + elem.get_arg() + "'")
|
||||
argument_remote_name = elem.get_arg()
|
||||
else:
|
||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||
|
||||
# check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
|
||||
configuration = config.Config()
|
||||
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == False:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
|
||||
all_project = mani.get_all_configs()
|
||||
debug.info("fetch : " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
debug.info("push: " + base_display)
|
||||
tools.wait_for_server_if_needed()
|
||||
#debug.debug("elem : " + str(elem))
|
||||
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == False:
|
||||
debug.error("can not push project that not exist")
|
||||
continue
|
||||
|
||||
if os.path.exists(os.path.join(git_repo_path,".git")) == False:
|
||||
# path already exist but it is not used to as a git repo ==> this is an error
|
||||
debug.error("path '" + git_repo_path + "' exist but not used for a git repository. Clean it and restart")
|
||||
|
||||
# get the current branch:
|
||||
# get local branch
|
||||
cmd = "git branch -a"
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret_branch = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||
list_branch = ret_branch[1].split('\n')
|
||||
list_branch2 = []
|
||||
list_branch3 = []
|
||||
select_branch = ""
|
||||
for elem_branch in list_branch:
|
||||
if len(elem_branch.split(" -> ")) != 1:
|
||||
continue
|
||||
if elem_branch[2:10] == "remotes/":
|
||||
elem_branch = elem_branch[:2] + elem_branch[10:]
|
||||
if elem_branch[:2] == "* ":
|
||||
list_branch2.append([elem_branch[2:], True])
|
||||
select_branch = elem_branch[2:]
|
||||
else:
|
||||
list_branch2.append([elem_branch[2:], False])
|
||||
list_branch3.append(elem_branch[2:])
|
||||
|
||||
# simply update the repository ...
|
||||
debug.verbose("Push project: ")
|
||||
# fetch the repository
|
||||
cmd = "git push"
|
||||
if argument_remote_name != "":
|
||||
cmd += " " + argument_remote_name
|
||||
else:
|
||||
cmd += " " + elem.select_remote["name"]
|
||||
cmd += " " + select_branch + ":" + select_branch
|
||||
debug.info("execute : " + cmd)
|
||||
multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||
|
145
island/actions/islandAction_status.py
Normal file
145
island/actions/islandAction_status.py
Normal file
@@ -0,0 +1,145 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
|
||||
from realog import debug
|
||||
from island import tools
|
||||
from island import env
|
||||
from island import multiprocess
|
||||
from island import config
|
||||
from island import manifest
|
||||
from island import commands
|
||||
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)
|
||||
##
|
||||
def help():
|
||||
return "Get the status of all the repositories"
|
||||
|
||||
##
|
||||
## @brief Add argument to the specific action
|
||||
## @param[in,out] my_args (death.Arguments) Argument manager
|
||||
## @param[in] section Name of the currect action
|
||||
##
|
||||
def add_specific_arguments(_my_args, _section):
|
||||
_my_args.add("r", "remote", haveParam=True, desc="Name of the remote server")
|
||||
|
||||
_my_args.add("t", "tags", haveParam=False, desc="Display if the commit is on a tag (and display it)")
|
||||
|
||||
##
|
||||
## @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
|
||||
##
|
||||
def execute(_arguments):
|
||||
argument_remote_name = ""
|
||||
argument_display_tag = False
|
||||
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() == "tags":
|
||||
argument_display_tag = True
|
||||
else:
|
||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||
|
||||
# check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
configuration = config.Config()
|
||||
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == False:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
is_modify_manifest = commands.check_repository_is_modify(env.get_island_path_manifest())
|
||||
if is_modify_manifest == True:
|
||||
debug.info("!!!!!!!!!!!! MANIFEST is modify !!!!!!!!")
|
||||
|
||||
all_project = mani.get_all_configs()
|
||||
debug.info("status of: " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
volatile = ""
|
||||
if elem.volatile == True:
|
||||
volatile = " (volatile)"
|
||||
debug.verbose("status : " + base_display)
|
||||
#debug.debug("elem : " + str(elem))
|
||||
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == False:
|
||||
debug.info(base_display + volatile + "\r\t\t\t\t\t\t\t\t\t" + " (not download)")
|
||||
continue
|
||||
|
||||
is_modify = commands.check_repository_is_modify(git_repo_path)
|
||||
list_branch = commands.get_list_branch_all(git_repo_path)
|
||||
select_branch = commands.get_current_branch(git_repo_path)
|
||||
debug.verbose("List all branch: " + str(list_branch))
|
||||
# get tracking branch
|
||||
tracking_remote_branch = commands.get_tracking_branch(git_repo_path, argument_remote_name, select_branch)
|
||||
if tracking_remote_branch == None:
|
||||
debug.info(base_display + volatile + "\r\t\t\t\t\t\t\t (NO BRANCH)")
|
||||
continue
|
||||
|
||||
modify_status = " "
|
||||
if is_modify == True:
|
||||
modify_status = " *** "
|
||||
|
||||
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_track_branch_sha1 = commands.get_revision_list_to_branch(git_repo_path, tracking_remote_branch)
|
||||
# remove all identical sha1 ==> not needed for this
|
||||
in_forward = 0
|
||||
for elem_sha1 in ret_current_branch_sha1:
|
||||
if elem_sha1 not in ret_track_branch_sha1:
|
||||
in_forward += 1
|
||||
in_behind = 0
|
||||
for elem_sha1 in ret_track_branch_sha1:
|
||||
if elem_sha1 not in ret_current_branch_sha1:
|
||||
in_behind += 1
|
||||
|
||||
behind_forward_comment = ""
|
||||
if in_forward != 0:
|
||||
behind_forward_comment += "forward=" + str(in_forward)
|
||||
if in_behind != 0:
|
||||
if in_forward != 0:
|
||||
behind_forward_comment += " "
|
||||
behind_forward_comment += "behind=" + str(in_behind)
|
||||
if behind_forward_comment != "":
|
||||
behind_forward_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t[" + behind_forward_comment + "]"
|
||||
|
||||
|
||||
tags_comment = ""
|
||||
# check the current tags of the repository
|
||||
if argument_display_tag == True:
|
||||
ret_current_tags = commands.get_tags_current(git_repo_path)
|
||||
debug.verbose("tags found: " + str(ret_current_tags))
|
||||
for elem_tag in ret_current_tags:
|
||||
if len(tags_comment) != 0:
|
||||
tags_comment += ","
|
||||
tags_comment += elem_tag
|
||||
if len(tags_comment) != 0:
|
||||
tags_comment = "\r\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t[" + 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:
|
||||
cmd = "git status --short"
|
||||
debug.verbose("execute : " + cmd)
|
||||
ret_diff = multiprocess.run_command(cmd, cwd=git_repo_path)
|
||||
tmp_color_red = "\033[31m"
|
||||
tmp_color_default= "\033[00m"
|
||||
debug.info(tmp_color_red + ret_diff[1] + tmp_color_default)
|
160
island/actions/islandAction_sync-local.py
Normal file
160
island/actions/islandAction_sync-local.py
Normal file
@@ -0,0 +1,160 @@
|
||||
#!/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 update_links
|
||||
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)
|
||||
##
|
||||
def help():
|
||||
return "Update all the branche to the trackin branch in local (no remote access)"
|
||||
|
||||
##
|
||||
## @brief Add argument to the specific action
|
||||
## @param[in,out] my_args (death.Arguments) Argument manager
|
||||
## @param[in] section Name of the currect action
|
||||
##
|
||||
def add_specific_arguments(my_args, section):
|
||||
my_args.add("r", "reset", haveParam=False, desc="Rebase the repository instead of 'reset --hard'")
|
||||
|
||||
##
|
||||
## @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)
|
||||
## -5 : env.ret_manifest_is_not_existing : Manifest does not exit
|
||||
## -10 : env.ret_action_is_not_existing : ACTION is not existing
|
||||
## -11 : env.ret_action_executing_system_error : ACTION execution system error
|
||||
## -12 : env.ret_action_wrong_parameters : ACTION Wrong parameters
|
||||
## -13 : env.ret_action_partial_done : ACTION partially done
|
||||
##
|
||||
def execute(_arguments):
|
||||
reset_instead_of_rebase = False
|
||||
for elem in _arguments:
|
||||
if elem.get_option_name() == "rebase":
|
||||
reset_instead_of_rebase = True
|
||||
debug.info("==> Request reset instead of rebase")
|
||||
else:
|
||||
debug.error("SYNC Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'", ret_value=env.ret_action_wrong_parameters)
|
||||
|
||||
# check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
|
||||
configuration = config.Config()
|
||||
|
||||
debug.info("update manifest : '" + str(env.get_island_path_manifest()) + "'")
|
||||
is_modify_manifest = commands.check_repository_is_modify(env.get_island_path_manifest())
|
||||
if is_modify_manifest == True:
|
||||
debug.warning("Manifest is modify")
|
||||
else:
|
||||
ret_track = commands.get_current_tracking_branch(env.get_island_path_manifest())
|
||||
is_forward = commands.is_forward(env.get_island_path_manifest(), ret_track)
|
||||
if is_forward == True:
|
||||
# fetch the repository
|
||||
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:
|
||||
debug.verbose("Check behind:")
|
||||
is_behind = commands.is_behind(env.get_island_path_manifest(), ret_track)
|
||||
if is_behind == False:
|
||||
# fetch the repository
|
||||
debug.info("sync-local: MANIFEST is up-to-date")
|
||||
else:
|
||||
if reset_instead_of_rebase == True:
|
||||
debug.info("sync-local: MANIFEST Reset to " + ret_track)
|
||||
commands.reset_hard(env.get_island_path_manifest(), ret_track)
|
||||
else:
|
||||
debug.info("sync-local: MANIFEST Rebase to " + ret_track)
|
||||
commands.rebase(env.get_island_path_manifest(), ret_track)
|
||||
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == False:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'", ret_value=env.ret_manifest_is_not_existing)
|
||||
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
|
||||
all_project = mani.get_all_configs()
|
||||
debug.info("synchronize : " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
count_error = 0
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
debug.info("----------------------------------------------------------------")
|
||||
debug.info("sync-local: " + base_display)
|
||||
#debug.debug("elem : " + str(elem))
|
||||
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == False:
|
||||
# The Repository does not exist ==> Nothing to do...
|
||||
debug.warning("sync-local: ==> Not download")
|
||||
count_error += 1
|
||||
continue
|
||||
|
||||
if os.path.exists(os.path.join(git_repo_path,".git")) == False:
|
||||
# path already exist but it is not used to as a git repo ==> this is an error
|
||||
debug.warning("sync-local: is already existing but not used for a git repository. Remove it and sync")
|
||||
count_error += 1
|
||||
continue
|
||||
|
||||
# simply update the repository ...
|
||||
debug.verbose("Check modify:")
|
||||
is_modify = commands.check_repository_is_modify(git_repo_path)
|
||||
if is_modify == True:
|
||||
# fetch the repository
|
||||
debug.warning("sync-local: Not update ==> the repository is modified (pass through)")
|
||||
count_error += 1
|
||||
continue
|
||||
debug.verbose("Check tracking and local branch:")
|
||||
# get tracking branch
|
||||
ret_track = commands.get_current_tracking_branch(git_repo_path)
|
||||
select_branch = commands.get_current_branch(git_repo_path)
|
||||
debug.debug("sync-local: check: " + select_branch + " ==> " + ret_track)
|
||||
debug.verbose("Check forward:")
|
||||
is_forward = commands.is_forward(git_repo_path, ret_track)
|
||||
if is_forward == True:
|
||||
# fetch the repository
|
||||
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
|
||||
continue
|
||||
debug.verbose("Check behind:")
|
||||
is_behind = commands.is_behind(git_repo_path, ret_track)
|
||||
if is_behind == False:
|
||||
# fetch the repository
|
||||
debug.info("sync-local: Nothing to do.")
|
||||
continue
|
||||
if reset_instead_of_rebase == True:
|
||||
debug.info("sync-local: Reset to " + ret_track)
|
||||
commands.reset_hard(git_repo_path, ret_track)
|
||||
else:
|
||||
debug.info("sync-local: Reset to " + ret_track)
|
||||
commands.rebase(git_repo_path, ret_track)
|
||||
if count_error != 0:
|
||||
debug.info(" ***********************************************************")
|
||||
debug.info(" ** local sync partial warning on " + str(count_error) + " repository")
|
||||
debug.info(" ***********************************************************")
|
||||
return env.ret_action_partial_done
|
||||
|
||||
## Update the links:
|
||||
have_error = update_links.update(configuration, mani, "sync-local")
|
||||
if have_error == True:
|
||||
return -1
|
||||
return None
|
||||
|
||||
|
||||
|
188
island/actions/islandAction_sync.py
Normal file
188
island/actions/islandAction_sync.py
Normal file
@@ -0,0 +1,188 @@
|
||||
#!/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 update_links
|
||||
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)
|
||||
##
|
||||
def help():
|
||||
return "Syncronize all the repository referenced"
|
||||
|
||||
##
|
||||
## @brief at the end of the help wa have the example section
|
||||
## @return (string) the Example description string
|
||||
##
|
||||
def help_example():
|
||||
return "island init https://git.heeroyui.org/atria-tools/island.git"
|
||||
|
||||
##
|
||||
## @brief Add argument to the specific action
|
||||
## @param[in,out] my_args (death.Arguments) Argument manager
|
||||
## @param[in] section Name of the currect action
|
||||
##
|
||||
def add_specific_arguments(my_args, section):
|
||||
my_args.add("d", "download", haveParam=False, desc="Just download the 'not download' repository")
|
||||
|
||||
##
|
||||
## @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
|
||||
##
|
||||
def execute(_arguments):
|
||||
just_download = False
|
||||
for elem in _arguments:
|
||||
if elem.get_option_name() == "download":
|
||||
just_download = True
|
||||
debug.info("find remote name: '" + elem.get_arg() + "'")
|
||||
else:
|
||||
debug.error("SYNC Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||
|
||||
# check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
|
||||
configuration = config.Config()
|
||||
|
||||
# TODO: Load Old manifect to check diff ...
|
||||
|
||||
debug.info("update manifest : '" + str(env.get_island_path_manifest()) + "'")
|
||||
is_modify_manifest = commands.check_repository_is_modify(env.get_island_path_manifest())
|
||||
if is_modify_manifest == True:
|
||||
commands.fetch(env.get_island_path_manifest(), "origin")
|
||||
else:
|
||||
commands.pull(env.get_island_path_manifest(), "origin")
|
||||
|
||||
file_source_manifest = os.path.join(env.get_island_path_manifest(), configuration.get_manifest_name())
|
||||
if os.path.exists(file_source_manifest) == False:
|
||||
debug.error("Missing manifest file : '" + str(file_source_manifest) + "'")
|
||||
|
||||
mani = manifest.Manifest(file_source_manifest)
|
||||
|
||||
all_project = mani.get_all_configs()
|
||||
debug.info("synchronize : " + str(len(all_project)) + " projects")
|
||||
id_element = 0
|
||||
for elem in all_project:
|
||||
id_element += 1
|
||||
base_display = tools.get_list_base_display(id_element, len(all_project), elem)
|
||||
debug.info("sync : " + base_display)
|
||||
tools.wait_for_server_if_needed()
|
||||
#debug.debug("elem : " + str(elem))
|
||||
git_repo_path = os.path.join(env.get_island_root_path(), elem.path)
|
||||
if os.path.exists(git_repo_path) == False:
|
||||
# this is a new clone ==> this is easy ...
|
||||
#clone the manifest repository
|
||||
address_manifest = ""
|
||||
### example git@git.plouf.com:basic_folder
|
||||
address_manifest = elem.select_remote["fetch"]
|
||||
if elem.select_remote["fetch"][0:4] == "git@" \
|
||||
and len(elem.select_remote["fetch"][4:].split(":")) <= 1:
|
||||
address_manifest += ":"
|
||||
else:
|
||||
address_manifest += "/"
|
||||
address_manifest += elem.name
|
||||
debug.info("clone the repo")
|
||||
ret = commands.clone(git_repo_path, address_manifest, branch_name=elem.branch, origin=elem.select_remote["name"])
|
||||
if ret[0] != "" \
|
||||
and ret[0] != False:
|
||||
# all is good, ready to get the system work corectly
|
||||
debug.info("'" + str(ret) + "'")
|
||||
debug.error("Clone repository does not work ... ")
|
||||
continue
|
||||
# add global mirror list
|
||||
for mirror in elem.select_remote["mirror"]:
|
||||
debug.verbose("Add global mirror: " + str(mirror))
|
||||
cmd = "git remote add " + mirror["name"] + " " + mirror["fetch"]
|
||||
if mirror["fetch"][0:4] == "git@":
|
||||
cmd += ":"
|
||||
else:
|
||||
cmd += "/"
|
||||
cmd += elem.name
|
||||
ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||
if ret != "" \
|
||||
and ret != False:
|
||||
# all is good, ready to get the system work corectly
|
||||
debug.info("'" + str(ret) + "'")
|
||||
debug.warning("Can not add global mirror ... ")
|
||||
continue
|
||||
debug.verbose("Add global mirror: " + str(mirror) + " (done)")
|
||||
#debug.info("plop " + str(elem.select_remote.keys()))
|
||||
# check submodule if requested:
|
||||
if elem.select_remote["sync"] == True \
|
||||
and os.path.exists(os.path.join(git_repo_path, ".gitmodules")) == True:
|
||||
debug.info(" ==> update submodule")
|
||||
cmd = "git submodule init"
|
||||
ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||
if ret != "" \
|
||||
and ret != False:
|
||||
# all is good, ready to get the system work corectly
|
||||
debug.info("'" + str(ret) + "'")
|
||||
debug.error("Can not init submodules ... ")
|
||||
continue
|
||||
cmd = "git submodule update"
|
||||
ret = multiprocess.run_command_direct(cmd, cwd=git_repo_path)
|
||||
if ret[:16] == "Submodule path '":
|
||||
#all is good ...
|
||||
debug.info(" " + ret)
|
||||
elif ret != "" \
|
||||
and ret != False:
|
||||
# all is good, ready to get the system work corectly
|
||||
debug.info("'" + str(ret) + "'")
|
||||
debug.error("Can not init submodules ... ")
|
||||
continue
|
||||
continue
|
||||
|
||||
if just_download == True:
|
||||
debug.info("SYNC: Already downloaded")
|
||||
continue
|
||||
|
||||
if os.path.exists(os.path.join(git_repo_path,".git")) == False:
|
||||
# path already exist but it is not used to as a git repo ==> this is an error
|
||||
debug.error("path '" + git_repo_path + "' is already existing but not used for a git repository. Clean it and restart")
|
||||
|
||||
# simply update the repository ...
|
||||
debug.verbose("Fetching project: ")
|
||||
|
||||
# get tracking branch
|
||||
ret_track = commands.get_current_tracking_branch(git_repo_path)
|
||||
is_modify = commands.check_repository_is_modify(git_repo_path)
|
||||
select_branch = commands.get_current_branch(git_repo_path)
|
||||
|
||||
if is_modify == True:
|
||||
# fetch the repository
|
||||
commands.fetch(git_repo_path, elem.select_remote["name"])
|
||||
debug.warning("[" + elem.name + "] Not update ==> the repository is modified (just fetch)")
|
||||
continue
|
||||
commands.pull(git_repo_path, elem.select_remote["name"])
|
||||
|
||||
debug.verbose("select branch = '" + select_branch + "' track: '" + str(ret_track) + "'")
|
||||
# check submodule if requested:
|
||||
if elem.select_remote["sync"] == True \
|
||||
and os.path.exists(os.path.join(git_repo_path, ".gitmodules")) == True:
|
||||
debug.info(" ==> sync submodule")
|
||||
commands.submodule_sync(git_repo_path)
|
||||
|
||||
## Update the links:
|
||||
have_error = update_links.update(configuration, mani, "sync-local")
|
||||
if have_error == True:
|
||||
return -1
|
||||
return None
|
86
island/actions/islandAction_volatile-add.py
Normal file
86
island/actions/islandAction_volatile-add.py
Normal file
@@ -0,0 +1,86 @@
|
||||
#!/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 commands
|
||||
from island import multiprocess
|
||||
from island import manifest
|
||||
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)
|
||||
##
|
||||
def help():
|
||||
return "Add a 'volatile' repository with a local path (this element is update as an element in the manifest but is not managed by the manifest)"
|
||||
|
||||
##
|
||||
## @brief Add argument to the specific action
|
||||
## @param[in,out] my_args (death.Arguments) Argument manager
|
||||
## @param[in] section Name of the currect action
|
||||
##
|
||||
def add_specific_arguments(my_args, section):
|
||||
my_args.add_arg("git repository", optionnal=False, desc="Git repositoty to download")
|
||||
my_args.add_arg("path", optionnal=False, desc="Path to install the new git repository")
|
||||
|
||||
##
|
||||
## @brief at the end of the help wa have the example section
|
||||
## @return (string) the Example description string
|
||||
##
|
||||
def help_example():
|
||||
return "island volatile-add https://git.heeroyui.org/atria-tools/island.git git"
|
||||
|
||||
##
|
||||
## @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)
|
||||
## -5 : env.ret_manifest_is_not_existing : Manifest does not exit
|
||||
## -10 : env.ret_action_is_not_existing : ACTION is not existing
|
||||
## -11 : env.ret_action_executing_system_error : ACTION execution system error
|
||||
## -12 : env.ret_action_wrong_parameters : ACTION Wrong parameters
|
||||
## -13 : env.ret_action_partial_done : ACTION partially done
|
||||
##
|
||||
def execute(_arguments):
|
||||
if len(_arguments) == 0:
|
||||
debug.error("Missing argument to execute the current action [git repository] [path]")
|
||||
|
||||
# the configuration availlable:
|
||||
path = ""
|
||||
address_git = ""
|
||||
for elem in _arguments:
|
||||
if elem.get_option_name() == "git repository":
|
||||
address_git = elem.get_arg()
|
||||
elif elem.get_option_name() == "path":
|
||||
path = elem.get_arg()
|
||||
else:
|
||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||
|
||||
if address_git == "":
|
||||
debug.error("volatile-add: Missing git repository address", env.ret_action_wrong_parameters)
|
||||
|
||||
debug.info("Add 'volatile' repository: '" + address_git + "' path='" + path + "'")
|
||||
|
||||
# check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
|
||||
# Update the current configuration:
|
||||
conf = config.Config()
|
||||
# TODO: Check if the local path does not exist in the manifest
|
||||
|
||||
if False == conf.add_volatile(address_git, path):
|
||||
return env.ret_action_executing_system_error
|
||||
conf.store()
|
||||
return None
|
||||
|
||||
|
53
island/actions/islandAction_volatile-list.py
Normal file
53
island/actions/islandAction_volatile-list.py
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/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 commands
|
||||
from island import multiprocess
|
||||
from island import manifest
|
||||
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)
|
||||
##
|
||||
def help():
|
||||
return "List all the volatil repository"
|
||||
|
||||
##
|
||||
## @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)
|
||||
## -5 : env.ret_manifest_is_not_existing : Manifest does not exit
|
||||
## -10 : env.ret_action_is_not_existing : ACTION is not existing
|
||||
## -11 : env.ret_action_executing_system_error : ACTION execution system error
|
||||
## -12 : env.ret_action_wrong_parameters : ACTION Wrong parameters
|
||||
## -13 : env.ret_action_partial_done : ACTION partially done
|
||||
##
|
||||
def execute(_arguments):
|
||||
for elem in _arguments:
|
||||
debug.error("Wrong argument: '" + elem.get_option_name() + "' '" + elem.get_arg() + "'")
|
||||
|
||||
# check system is OK
|
||||
manifest.check_lutin_is_init()
|
||||
|
||||
conf = config.Config()
|
||||
volatiles = conf.get_volatile()
|
||||
debug.info("List of all volatiles repository: ")
|
||||
for elem in volatiles:
|
||||
debug.info("\t" + elem["path"] + "\r\t\t\t\t" + elem["git_address"])
|
||||
|
||||
return None
|
||||
|
||||
|
43
island/actions/update_links.py
Normal file
43
island/actions/update_links.py
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/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
|
||||
import os
|
||||
|
||||
## Update the links:
|
||||
def update(configuration, mani, type_call):
|
||||
# TODO: do not remove link when not needed
|
||||
if len(configuration.get_links()) != 0 \
|
||||
or len(mani.get_links()) != 0:
|
||||
debug.info(type_call + ": remove old links ...")
|
||||
for elem in configuration.get_links():
|
||||
base_path = os.path.join(env.get_island_root_path(), elem["destination"])
|
||||
debug.info(type_call + ": link: " + str(base_path))
|
||||
if os.path.islink(base_path) == True:
|
||||
os.unlink(base_path)
|
||||
else:
|
||||
debug.error(type_call + ": remove link is not authorised ==> not a link", crash=False)
|
||||
have_error = True
|
||||
configuration.clear_links()
|
||||
debug.info(type_call + ": add new links ...")
|
||||
for elem in mani.get_links():
|
||||
base_path = os.path.join(env.get_island_root_path(), elem["destination"])
|
||||
source_path = os.path.join(env.get_island_root_path(), elem["source"])
|
||||
debug.info(type_call + ": link: " + str(base_path))
|
||||
if os.path.exists(base_path) == True:
|
||||
debug.error(type_call + ": create link is not possible ==> path already exist", crash=False)
|
||||
have_error = True
|
||||
else:
|
||||
tools.create_directory_of_file(base_path)
|
||||
os.symlink(source_path, base_path)
|
||||
configuration.add_link(elem["source"], elem["destination"])
|
||||
configuration.store()
|
408
island/commands.py
Normal file
408
island/commands.py
Normal file
@@ -0,0 +1,408 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import errno
|
||||
import fnmatch
|
||||
import stat
|
||||
# Local import
|
||||
from realog import debug
|
||||
from . import env
|
||||
from . import multiprocess
|
||||
from . import debug
|
||||
|
||||
|
||||
|
||||
def generic_display_error(return_value, type_name, error_only=False, availlable_return=[0], display_if_nothing=True):
|
||||
debug.verbose(str(return_value))
|
||||
if return_value[0] in availlable_return:
|
||||
if error_only == True:
|
||||
return
|
||||
display = False
|
||||
if return_value[1] != "":
|
||||
debug.info(return_value[1])
|
||||
display = True
|
||||
if return_value[2] != "":
|
||||
debug.warning(return_value[2])
|
||||
display = True
|
||||
if display_if_nothing == False:
|
||||
return
|
||||
if display == False:
|
||||
debug.verbose("GIT(" + type_name + "): All done OK")
|
||||
else:
|
||||
display = False
|
||||
if return_value[1] != "":
|
||||
debug.warning("ERROR GIT(" + type_name + ") 1:" + return_value[1])
|
||||
display = True
|
||||
if return_value[2] != "":
|
||||
debug.warning("ERROR GIT(" + type_name + ") 2:" + return_value[2])
|
||||
display = True
|
||||
if display == False:
|
||||
debug.warning("ERROR GIT(" + type_name + "): Unknow error return_value=" + str(return_value[0]))
|
||||
|
||||
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
def check_repository_is_modify(path_repository):
|
||||
# check if the repository is modify
|
||||
cmd = "git diff --quiet"
|
||||
debug.verbose("execute : " + cmd)
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "check_repository_is_modify", error_only=True, availlable_return=[0,1], display_if_nothing=False)
|
||||
ret_diff = return_value
|
||||
if ret_diff[0] == 0:
|
||||
return False
|
||||
return True
|
||||
|
||||
def get_list_branch_meta(path_repository):
|
||||
# get local branch
|
||||
cmd = "git branch -a"
|
||||
debug.verbose("execute : " + cmd)
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "get_list_branch_meta", error_only=True)
|
||||
ret_branch = return_value
|
||||
list_branch = ret_branch[1].split('\n')
|
||||
out = []
|
||||
for elem_branch in list_branch:
|
||||
is_remote = False
|
||||
branch_name = ""
|
||||
is_selected = False
|
||||
if len(elem_branch.split(" -> ")) != 1:
|
||||
continue
|
||||
# separate the remote element
|
||||
if elem_branch[2:10] == "remotes/":
|
||||
elem_branch = elem_branch[:2] + elem_branch[10:]
|
||||
is_remote = True
|
||||
# separate select branch
|
||||
if elem_branch[:2] == "* ":
|
||||
is_selected = True
|
||||
branch_name = elem_branch[2:]
|
||||
else:
|
||||
branch_name = elem_branch[2:]
|
||||
out.append({
|
||||
"remote": is_remote,
|
||||
"name": branch_name,
|
||||
"select": is_selected
|
||||
})
|
||||
debug.extreme_verbose("List all branch Meta: " + str(out))
|
||||
return out
|
||||
|
||||
|
||||
def get_list_branch_all(path_repository):
|
||||
tmp = get_list_branch_meta(path_repository)
|
||||
out = []
|
||||
for elem in tmp:
|
||||
out.append(elem["name"])
|
||||
debug.verbose("List all branch: " + str(out))
|
||||
return out
|
||||
|
||||
def get_list_branch_local(path_repository):
|
||||
tmp = get_list_branch_meta(path_repository)
|
||||
out = []
|
||||
for elem in tmp:
|
||||
if elem["remote"] == False:
|
||||
out.append(elem["name"])
|
||||
debug.verbose("List local branch: " + str(out))
|
||||
return out
|
||||
|
||||
def get_list_branch_remote(path_repository):
|
||||
tmp = get_list_branch_meta(path_repository)
|
||||
out = []
|
||||
for elem in tmp:
|
||||
if elem["remote"] == True:
|
||||
out.append(elem["name"])
|
||||
debug.verbose("List remote branch: " + str(out))
|
||||
return out
|
||||
|
||||
def get_current_branch(path_repository):
|
||||
tmp = get_list_branch_meta(path_repository)
|
||||
for elem in tmp:
|
||||
if elem["select"] == True:
|
||||
debug.verbose("List local branch: " + str(elem["name"]))
|
||||
return elem["name"]
|
||||
debug.verbose("List local branch: None" )
|
||||
return None
|
||||
|
||||
def get_current_tracking_branch(path_repository):
|
||||
# get tracking branch
|
||||
cmd = "git rev-parse --abbrev-ref --symbolic-full-name @{u}"
|
||||
debug.verbose("execute : " + cmd)
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
if return_value[1] == "@{u}":
|
||||
debug.warning("in '" + path_repository + "' no tracking branch is specify")
|
||||
return None
|
||||
generic_display_error(return_value, "get_current_tracking_branch", error_only=True)
|
||||
return return_value[1]
|
||||
|
||||
def get_revision_list_to_branch(path_repository, branch):
|
||||
cmd = "git rev-list " + branch
|
||||
debug.verbose("execute : " + cmd)
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "get_revision_list_to_branch", error_only=True)
|
||||
return return_value[1].split('\n')
|
||||
|
||||
def get_specific_commit_message(path_repository, sha_1):
|
||||
if sha_1 == None or sha_1 == "":
|
||||
return ""
|
||||
cmd = "git log --format=%B -n 1 " + sha_1
|
||||
debug.verbose("execute : " + cmd)
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "get_specific_commit_message", error_only=True)
|
||||
return return_value[1].split('\n')[0]
|
||||
|
||||
def get_sha1_for_branch(path_repository, branch_name):
|
||||
if branch_name == None or branch_name == "":
|
||||
return None
|
||||
cmd = "git rev-parse " + branch_name
|
||||
debug.verbose("execute : " + cmd)
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "get_sha1_for_branch", error_only=True)
|
||||
return return_value[1].split('\n')[0]
|
||||
|
||||
|
||||
def get_tags_current(path_repository):
|
||||
cmd = "git tag --points-at"
|
||||
debug.verbose("execute : " + cmd)
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "get_tags_current", error_only=True)
|
||||
return return_value[1].split('\n')
|
||||
|
||||
def get_tags(path_repository):
|
||||
cmd = "git tag"
|
||||
debug.verbose("execute : " + cmd)
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "get_tags", error_only=True)
|
||||
return return_value[1].split('\n')
|
||||
|
||||
def get_tags_remote(path_repository, remote_name):
|
||||
if remote_name == "" or remote_name == None:
|
||||
return get_current_tracking_branch(path_repository)
|
||||
cmd = "git ls-remote --tags " + remote_name
|
||||
debug.verbose("execute : " + cmd)
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "get_tags_remote", error_only=True)
|
||||
list_element = return_value[1].split('\n')
|
||||
debug.verbose(" receive: " + str(list_element))
|
||||
#6bc01117e85d00686ae2d423193a161e82df9a44 refs/tags/0.1.0
|
||||
#7ef9caa51cf3744de0f46352e5aa07bd4980fe89 refs/tags/v0.2.0
|
||||
#870e8e039b0a98370a9d23844f0af66824c57a5f refs/tags/v0.2.0^{}
|
||||
#16707e17e58f16b3409f8c64df7f595ba7dcf499 refs/tags/v0.3.0
|
||||
#dfb97c3dfea776e5c4862dc9f60f8c5ad83b55eb refs/tags/v0.3.0^{}
|
||||
out = []
|
||||
for elem in list_element:
|
||||
cut = elem.split("\t")
|
||||
if len(cut) != 2:
|
||||
continue
|
||||
if cut[1][-3:] == "^{}":
|
||||
# specific usage for the annotated commit
|
||||
continue
|
||||
if cut[1][:10] == "refs/tags/":
|
||||
out.append(cut[1][10:])
|
||||
else:
|
||||
out.append(cut[1])
|
||||
return out
|
||||
|
||||
def get_tracking_branch(path_repository, remote_name, select_branch):
|
||||
# get tracking branch
|
||||
if remote_name == "" or remote_name == None:
|
||||
return get_current_tracking_branch(path_repository)
|
||||
list_branch_remote = get_list_branch_remote(path_repository)
|
||||
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:
|
||||
debug.debug(" ==> can not get remote branch")
|
||||
return None
|
||||
return remote_name + "/" + select_branch
|
||||
|
||||
|
||||
def merge_branch_on_master(path_repository, branch_name):
|
||||
if branch_name == None or branch_name == "":
|
||||
raise "Missing branch name"
|
||||
cmd = "git merge --no-ff " + branch_name + " --message \"Merge branch '" + branch_name + "' into 'master'\""
|
||||
debug.verbose("execute : " + cmd)
|
||||
# TODO: check if the command work correctly
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "merge_branch_on_master", error_only=True)
|
||||
return return_value
|
||||
|
||||
|
||||
def add_file(path_repository, file_path):
|
||||
if file_path == None or file_path == "":
|
||||
raise "Missing file_path name"
|
||||
cmd = "git add " + file_path
|
||||
debug.verbose("execute : " + cmd)
|
||||
# TODO: check if the command work correctly
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "add_file", error_only=True)
|
||||
return return_value
|
||||
|
||||
|
||||
def commit_all(path_repository, comment):
|
||||
if comment == None or comment == "":
|
||||
raise "Missing comment description"
|
||||
cmd = 'git commit -a --message "' + comment +'"'
|
||||
debug.verbose("execute : " + cmd)
|
||||
# TODO: check if the command work correctly
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "commit_all", error_only=True)
|
||||
return return_value
|
||||
|
||||
def tag(path_repository, tag_name):
|
||||
if tag_name == None or tag_name == "":
|
||||
raise "Missing tag name"
|
||||
tag_name = tag_name.replace(" ", "_")
|
||||
cmd = 'git tag ' + tag_name + ' --message "[TAG] create tag ' + tag_name +'"'
|
||||
debug.verbose("execute : " + cmd)
|
||||
# TODO: check if the command work correctly
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "tag", error_only=True)
|
||||
return return_value
|
||||
|
||||
def checkout(path_repository, branch_name):
|
||||
if branch_name == None or branch_name == "":
|
||||
raise "Missing branch name"
|
||||
cmd = 'git checkout ' + branch_name
|
||||
debug.verbose("execute : " + cmd)
|
||||
# TODO: check if the command work correctly
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "checkout", error_only=True)
|
||||
return return_value
|
||||
|
||||
def reset_hard(path_repository, destination):
|
||||
if destination == None or destination == "":
|
||||
raise "Missing destination 'sha1' or 'branch name'"
|
||||
cmd = 'git reset --hard ' + destination
|
||||
debug.verbose("execute : " + cmd)
|
||||
# TODO: check if the command work correctly
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "reset_hard", error_only=True)
|
||||
return return_value
|
||||
|
||||
def rebase(path_repository, destination):
|
||||
if destination == None or destination == "":
|
||||
raise "Missing destination 'sha1' or 'branch name'"
|
||||
cmd = 'git rebase ' + destination
|
||||
debug.verbose("execute : " + cmd)
|
||||
# TODO: check if the command work correctly
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "rebase", error_only=True)
|
||||
return return_value
|
||||
|
||||
|
||||
def clone(path_repository, address, branch_name = None, origin=None):
|
||||
if address == None or address == "":
|
||||
raise "Missing address"
|
||||
cmd = 'git clone ' + address
|
||||
if branch_name != None and branch_name == "":
|
||||
cmd += " --branch " + branch_name
|
||||
if origin != None and origin == "":
|
||||
cmd += " --origin " + origin
|
||||
if path_repository != None and path_repository != "":
|
||||
cmd += " " + path_repository
|
||||
debug.verbose("execute : " + cmd)
|
||||
if os.path.exists(path_repository) == True:
|
||||
debug.warning("Can not clone repository path already exist")
|
||||
return False
|
||||
return_value = multiprocess.run_command(cmd)
|
||||
generic_display_error(return_value, "clone", error_only=True)
|
||||
return return_value
|
||||
|
||||
|
||||
def fetch(path_repository, remote_name, prune=True):
|
||||
cmd = 'git fetch ' + remote_name
|
||||
if prune == True:
|
||||
cmd += " --prune"
|
||||
debug.verbose("execute : " + cmd)
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "fetch")
|
||||
return return_value
|
||||
|
||||
def pull(path_repository, remote_name, prune=True):
|
||||
if remote_name == None or remote_name == "":
|
||||
raise "Missing remote_name"
|
||||
cmd = 'git pull ' + remote_name
|
||||
if prune == True:
|
||||
cmd += " --prune"
|
||||
debug.verbose("execute : " + cmd)
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "pull")
|
||||
return return_value
|
||||
|
||||
def push(path_repository, remote_name, elements):
|
||||
if remote_name == None or remote_name == "":
|
||||
raise "Missing remote_name"
|
||||
if len(elements) == 0:
|
||||
raise "No elements to push on server"
|
||||
cmd = 'git push ' + remote_name
|
||||
for elem in elements:
|
||||
cmd += " " + elem
|
||||
debug.verbose("execute : " + cmd)
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "push")
|
||||
return return_value
|
||||
|
||||
|
||||
def submodule_sync(path_repository, remote_name):
|
||||
cmd = "git submodule sync"
|
||||
debug.verbose("execute : " + cmd)
|
||||
return_value = multiprocess.run_command(cmd, cwd=path_repository)
|
||||
generic_display_error(return_value, "submodule_sync")
|
||||
"""
|
||||
if ret[:31] == "Synchronizing submodule url for":
|
||||
#all is good ...
|
||||
debug.info(" " + ret)
|
||||
elif ret != "" \
|
||||
and ret != False:
|
||||
# all is good, ready to get the system work corectly
|
||||
debug.info("'" + ret + "'")
|
||||
debug.error("Can not sync submodules ... ")
|
||||
"""
|
||||
|
||||
|
||||
|
||||
def get_forward(path_repository, branch_name):
|
||||
if branch_name == None or branch_name == "":
|
||||
raise "get_fast_forward: Missing branch_name"
|
||||
select_branch = get_current_branch(path_repository)
|
||||
# get tracking branch
|
||||
ret_current_branch_sha1 = get_revision_list_to_branch(path_repository, select_branch)
|
||||
ret_track_branch_sha1 = get_revision_list_to_branch(path_repository, branch_name)
|
||||
# count the number of commit fast forward
|
||||
forward_count = 0
|
||||
for elem_sha1 in ret_current_branch_sha1:
|
||||
if elem_sha1 not in ret_track_branch_sha1:
|
||||
forward_count += 1
|
||||
return forward_count
|
||||
|
||||
def is_forward(path_repository, branch_name):
|
||||
return get_forward(path_repository, branch_name) != 0;
|
||||
|
||||
|
||||
|
||||
def get_behind(path_repository, branch_name):
|
||||
if branch_name == None or branch_name == "":
|
||||
raise "get_fast_forward: Missing branch_name"
|
||||
select_branch = get_current_branch(path_repository)
|
||||
# get tracking branch
|
||||
ret_current_branch_sha1 = get_revision_list_to_branch(path_repository, select_branch)
|
||||
ret_track_branch_sha1 = get_revision_list_to_branch(path_repository, branch_name)
|
||||
# count the number of commit behind
|
||||
behind_count = 0
|
||||
for elem_sha1 in ret_track_branch_sha1:
|
||||
if elem_sha1 not in ret_current_branch_sha1:
|
||||
behind_count += 1
|
||||
return behind_count
|
||||
|
||||
def is_behind(path_repository, branch_name):
|
||||
return get_behind(path_repository, branch_name) != 0;
|
||||
|
||||
|
155
island/config.py
Normal file
155
island/config.py
Normal file
@@ -0,0 +1,155 @@
|
||||
#!/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
|
||||
|
||||
|
||||
env.get_island_path_config()
|
||||
|
||||
|
||||
class Config():
|
||||
def __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
|
||||
def 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
|
||||
|
||||
def 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())
|
||||
|
||||
def 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
|
||||
|
||||
def 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
|
||||
|
||||
def set_manifest(self, value):
|
||||
self._repo = value
|
||||
|
||||
def get_manifest(self):
|
||||
return self._repo
|
||||
|
||||
def set_branch(self, value):
|
||||
self._branch = value
|
||||
|
||||
def get_branch(self):
|
||||
return self._branch
|
||||
|
||||
def set_manifest_name(self, value):
|
||||
self._manifest_name = value
|
||||
|
||||
def get_manifest_name(self):
|
||||
return self._manifest_name
|
||||
|
||||
def 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
|
||||
|
||||
def get_volatile(self):
|
||||
return copy.deepcopy(self._volatiles)
|
||||
|
||||
|
||||
def get_links(self):
|
||||
return self._curent_link
|
||||
|
||||
def 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
|
||||
|
||||
def 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")
|
||||
|
||||
def clear_links(self):
|
||||
self._curent_link = []
|
||||
|
||||
|
142
island/env.py
Normal file
142
island/env.py
Normal file
@@ -0,0 +1,142 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
|
||||
# Local import
|
||||
from realog import debug
|
||||
|
||||
import os
|
||||
|
||||
|
||||
system_base_name = "island"
|
||||
|
||||
def set_system_base_name(val):
|
||||
global system_base_name
|
||||
system_base_name = val
|
||||
debug.debug("Set basename: '" + str(system_base_name) + "'")
|
||||
|
||||
def get_system_base_name():
|
||||
global system_base_name
|
||||
return system_base_name
|
||||
|
||||
def get_system_config_name():
|
||||
global system_base_name
|
||||
return system_base_name + "Config.py"
|
||||
|
||||
|
||||
fetch_manifest = True
|
||||
|
||||
def set_fetch_manifest(val):
|
||||
global fetch_manifest
|
||||
fetch_manifest = val
|
||||
|
||||
def get_fetch_manifest():
|
||||
global fetch_manifest
|
||||
return fetch_manifest
|
||||
|
||||
|
||||
wait_between_sever_command = 0
|
||||
|
||||
def set_wait_between_sever_command(val):
|
||||
global wait_between_sever_command
|
||||
wait_between_sever_command = val
|
||||
|
||||
def get_wait_between_sever_command():
|
||||
global wait_between_sever_command
|
||||
return wait_between_sever_command
|
||||
|
||||
filter_command = ""
|
||||
|
||||
def set_filter_command(val):
|
||||
global filter_command
|
||||
filter_command = val
|
||||
|
||||
def get_filter_command():
|
||||
global filter_command
|
||||
return filter_command
|
||||
|
||||
def need_process_with_filter(data):
|
||||
global filter_command
|
||||
if filter_command == "":
|
||||
return True
|
||||
if len(data) < len(filter_command):
|
||||
return False
|
||||
if data[:len(filter_command)] == filter_command:
|
||||
return True
|
||||
return False
|
||||
|
||||
display_folder_instead_of_git_name = True
|
||||
|
||||
def set_display_folder_instead_of_git_name(val):
|
||||
global display_folder_instead_of_git_name
|
||||
display_folder_instead_of_git_name = val
|
||||
|
||||
def get_display_folder_instead_of_git_name():
|
||||
global display_folder_instead_of_git_name
|
||||
return display_folder_instead_of_git_name
|
||||
|
||||
island_root_path = os.path.join(os.getcwd())
|
||||
if os.path.exists(os.path.join(island_root_path, "." + get_system_base_name())) == True:
|
||||
# all is good ...
|
||||
pass
|
||||
elif os.path.exists(os.path.join(island_root_path, "..", "." + get_system_base_name())) == True:
|
||||
island_root_path = os.path.join(os.getcwd(), "..")
|
||||
elif os.path.exists(os.path.join(island_root_path, "..", "..", "." + get_system_base_name())) == True:
|
||||
island_root_path = os.path.join(os.getcwd(), "..", "..")
|
||||
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "." + get_system_base_name())) == True:
|
||||
island_root_path = os.path.join(os.getcwd(), "..", "..", "..")
|
||||
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "..", "." + get_system_base_name())) == True:
|
||||
island_root_path = os.path.join(os.getcwd(), "..", "..", "..", "..")
|
||||
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "..", "..", "." + get_system_base_name())) == True:
|
||||
island_root_path = os.path.join(os.getcwd(), "..", "..", "..", "..", "..")
|
||||
elif os.path.exists(os.path.join(island_root_path, "..", "..", "..", "..", "..", "..", "." + get_system_base_name())) == True:
|
||||
island_root_path = os.path.join(os.getcwd(), "..", "..", "..", "..", "..", "..")
|
||||
else:
|
||||
#debug.error("the root path of " + get_system_base_name() + " must not be upper that 6 parent path")
|
||||
pass
|
||||
island_path_user_config = os.path.join(island_root_path, get_system_config_name())
|
||||
island_path = os.path.join(island_root_path, "." + get_system_base_name())
|
||||
island_path_config_old = os.path.join(island_path, "config.txt")
|
||||
island_path_config = os.path.join(island_path, "config.json")
|
||||
island_path_manifest = os.path.join(island_path, "manifest")
|
||||
|
||||
##
|
||||
## @brief to use later to know where the ".island" parent path is ...
|
||||
## @return the parent path of the ".island"
|
||||
##
|
||||
def get_island_root_path():
|
||||
global island_root_path
|
||||
return island_root_path
|
||||
|
||||
def get_island_path():
|
||||
global island_path
|
||||
return island_path
|
||||
|
||||
def get_island_path_config():
|
||||
global island_path_config
|
||||
return island_path_config
|
||||
|
||||
def get_island_path_config_old():
|
||||
global island_path_config_old
|
||||
return island_path_config_old
|
||||
|
||||
def get_island_path_manifest():
|
||||
global island_path_manifest
|
||||
return island_path_manifest
|
||||
|
||||
def get_island_path_user_config():
|
||||
global island_path_user_config
|
||||
return island_path_user_config
|
||||
|
||||
|
||||
ret_manifest_is_not_existing = -5
|
||||
ret_action_is_not_existing = -10
|
||||
ret_action_executing_system_error = -11
|
||||
ret_action_wrong_parameters = -12
|
||||
ret_action_partial_done = -13
|
@@ -10,28 +10,17 @@
|
||||
import platform
|
||||
import sys
|
||||
# Local import
|
||||
from . import debug
|
||||
from realog import debug
|
||||
|
||||
# print os.name # ==> 'posix'
|
||||
if platform.system() == "Linux":
|
||||
OS = "Linux"
|
||||
HOST_DEFAULT_COMPILATOR = "gcc"
|
||||
elif platform.system() == "Windows":
|
||||
OS = "Windows"
|
||||
HOST_DEFAULT_COMPILATOR = "gcc"
|
||||
elif platform.system() == "Darwin":
|
||||
OS = "MacOs"
|
||||
HOST_DEFAULT_COMPILATOR = "clang"
|
||||
else:
|
||||
debug.error("Unknow the Host OS ... '" + platform.system() + "'")
|
||||
|
||||
debug.debug("host.OS = " + OS)
|
||||
|
||||
|
||||
if sys.maxsize > 2**32:
|
||||
BUS_SIZE = 64
|
||||
else:
|
||||
BUS_SIZE = 32
|
||||
|
||||
debug.debug("host.BUS_SIZE = " + str(BUS_SIZE))
|
||||
|
411
island/manifest.py
Normal file
411
island/manifest.py
Normal file
@@ -0,0 +1,411 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
import platform
|
||||
import sys
|
||||
import os
|
||||
import copy
|
||||
# Local import
|
||||
from realog import debug
|
||||
from . import tools
|
||||
from . import env
|
||||
from . import multiprocess
|
||||
from . import config
|
||||
|
||||
from lxml import etree
|
||||
|
||||
class RepoConfig():
|
||||
def __init__(self):
|
||||
self.name = ""
|
||||
self.path = ""
|
||||
self.remotes = [] # list of all remotes, with the upstream elements (needed for third party integrations)
|
||||
self.select_remote = ""
|
||||
self.branch = ""
|
||||
self.volatile = False
|
||||
|
||||
class LinkConfig():
|
||||
def __init__(self):
|
||||
self.source = ""
|
||||
self.destination = ""
|
||||
|
||||
|
||||
def 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
|
||||
|
||||
def 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():
|
||||
def __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 = []
|
||||
# load the manifest
|
||||
self._load()
|
||||
# check error in manifest (double path ...)
|
||||
self._check_double_path([])
|
||||
|
||||
def get_links(self):
|
||||
return self.links
|
||||
|
||||
def _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 = os.path.join(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 = ""
|
||||
for attr in child.attrib:
|
||||
if attr == "name":
|
||||
name = child.attrib[attr]
|
||||
elif attr == "path":
|
||||
path = child.attrib[attr]
|
||||
else:
|
||||
debug.error("(l:" + str(child.sourceline) + ") Parsing the manifest: Unknow '" + child.tag + "' attibute : '" + attr + "', availlable:[name,revision,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,
|
||||
})
|
||||
debug.debug("(l:" + str(child.sourceline) + ") find '" + child.tag + "' : name='" + name + "' path='" + path + "'");
|
||||
continue
|
||||
if child.tag == "option":
|
||||
# not managed ==> future use
|
||||
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.warning("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
|
||||
|
||||
|
||||
def _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
|
||||
|
||||
def _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 + " ")
|
||||
|
||||
def 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 = RepoConfig()
|
||||
conf.name = elem["name"]
|
||||
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.Config()
|
||||
for elem in conf_global.get_volatile():
|
||||
conf = RepoConfig()
|
||||
base_volatile, repo_volatile = 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
|
||||
|
||||
|
||||
def split_repo(git_repo):
|
||||
debug.verbose("parse git repo in RAW: " + str(git_repo))
|
||||
if len(git_repo) > 4 \
|
||||
and git_repo[:4] == "http":
|
||||
# http://wdfqsdfqs@qsdfqsdf/qsdfqsdf/qsdfqsdf/qsdfqs.git find the 3rd '/' and cut at this point
|
||||
elements = git_repo.split('/')
|
||||
if len(elements) < 4:
|
||||
debug.error("Can not parse the git repository : '" + str(git_repo) + "' wrong format http?://xxx@xxx.xxx/****")
|
||||
base = elements[0] + "/" + elements[1] + "/" + elements[2]
|
||||
repo = git_repo[len(base)+1:]
|
||||
elif len(git_repo) > 3 \
|
||||
and git_repo[:3] == "git":
|
||||
# git@qsdfqsdf:qsdfqsdf/qsdfqsdf/qsdfqs.git find the 1st ':' and cut at this point
|
||||
elements = git_repo.split(':')
|
||||
if len(elements) < 2:
|
||||
debug.error("Can not parse the git repository : '" + str(git_repo) + "' wrong format git@xxx.xxx:****")
|
||||
base = elements[0]
|
||||
repo = git_repo[len(base)+1:]
|
||||
else:
|
||||
debug.error("Can not parse the git repository : '" + str(git_repo) + "' does not start with ['http', 'git']")
|
||||
debug.verbose(" base: " + str(base))
|
||||
debug.verbose(" repo: " + str(repo))
|
||||
return (base, repo)
|
91
island/multiprocess.py
Normal file
91
island/multiprocess.py
Normal file
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import sys
|
||||
import os
|
||||
import subprocess
|
||||
import shlex
|
||||
# Local import
|
||||
from realog import debug
|
||||
from . import tools
|
||||
from . import env
|
||||
|
||||
|
||||
def run_command_direct_shell(cmd_line, cwd=None, shell=False):
|
||||
# prepare command line:
|
||||
args = shlex.split(cmd_line)
|
||||
debug.verbose("cmd = " + str(args))
|
||||
subprocess.check_call(args, shell=shell)
|
||||
return ""
|
||||
##
|
||||
## @brief Execute the command and ruturn generate data
|
||||
##
|
||||
def run_command_direct(cmd_line, cwd=None):
|
||||
# prepare command line:
|
||||
args = shlex.split(cmd_line)
|
||||
debug.verbose("cmd = " + str(args))
|
||||
"""
|
||||
if True:
|
||||
subprocess.check_call(args)
|
||||
return ""
|
||||
"""
|
||||
try:
|
||||
# create the subprocess
|
||||
#p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
#p = subprocess.check_call(args)
|
||||
"""
|
||||
if cwd != None:
|
||||
debug.info("path = " + cwd)
|
||||
"""
|
||||
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)
|
||||
except subprocess.CalledProcessError as e:
|
||||
debug.error("subprocess.CalledProcessError : " + str(args))
|
||||
except:
|
||||
debug.error("Exception on : " + str(args))
|
||||
# launch the subprocess:
|
||||
output, err = p.communicate()
|
||||
if sys.version_info >= (3, 0):
|
||||
output = output.decode("utf-8")
|
||||
err = err.decode("utf-8")
|
||||
# Check errors:
|
||||
if p.returncode == 0:
|
||||
if output == None:
|
||||
return err[:-1];
|
||||
return output[:-1];
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def run_command(cmd_line, cwd=None):
|
||||
# prepare command line:
|
||||
args = shlex.split(cmd_line)
|
||||
debug.verbose("cmd = " + str(args))
|
||||
try:
|
||||
# create the subprocess
|
||||
"""
|
||||
if cwd != None:
|
||||
debug.info("path = " + cwd)
|
||||
"""
|
||||
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=cwd)
|
||||
except subprocess.CalledProcessError as e:
|
||||
debug.error("subprocess.CalledProcessError : " + str(args))
|
||||
except:
|
||||
debug.error("Exception on : " + str(args))
|
||||
# launch the subprocess:
|
||||
output, err = p.communicate()
|
||||
if sys.version_info >= (3, 0):
|
||||
output = output.decode("utf-8")
|
||||
err = err.decode("utf-8")
|
||||
# Check error :
|
||||
return [p.returncode, output[:-1], err[:-1]]
|
@@ -13,8 +13,9 @@ import shutil
|
||||
import errno
|
||||
import fnmatch
|
||||
import stat
|
||||
import time
|
||||
# Local import
|
||||
from . import debug
|
||||
from realog import debug
|
||||
from . import env
|
||||
|
||||
"""
|
||||
@@ -29,13 +30,18 @@ def get_run_path():
|
||||
def get_current_path(file):
|
||||
return os.path.dirname(os.path.realpath(file))
|
||||
|
||||
def create_directory_of_file(file):
|
||||
path = os.path.dirname(file)
|
||||
|
||||
def create_directory(path):
|
||||
try:
|
||||
os.stat(path)
|
||||
except:
|
||||
os.makedirs(path)
|
||||
|
||||
def create_directory_of_file(file):
|
||||
path = os.path.dirname(file)
|
||||
create_directory(path)
|
||||
|
||||
|
||||
def get_list_sub_path(path):
|
||||
# TODO : os.listdir(path)
|
||||
for dirname, dirnames, filenames in os.walk(path):
|
||||
@@ -81,6 +87,20 @@ def version_to_string(version):
|
||||
version_ID += str(id)
|
||||
return version_ID
|
||||
|
||||
def version_string_to_list(version):
|
||||
debug.verbose("parse version string '" + version +"'")
|
||||
out = []
|
||||
if version == "":
|
||||
return [0, 0, 0]
|
||||
elems = version.split("-")
|
||||
if len(elems[0].split(".")) <= 1:
|
||||
debug.error("Can not parde a version with wrong version model '" + version +"'")
|
||||
for elem in elems[0].split("."):
|
||||
out.append(int(elem))
|
||||
if len(elems) >= 2:
|
||||
out.append(elems[1])
|
||||
return out
|
||||
|
||||
##
|
||||
## @brief Write data in a specific path.
|
||||
## @param[in] path Path of the data might be written.
|
||||
@@ -270,3 +290,22 @@ def remove_element(data, to_remove):
|
||||
return out;
|
||||
|
||||
|
||||
def get_list_base_display(id, count, elem):
|
||||
if env.get_display_folder_instead_of_git_name() == False:
|
||||
return str(id) + "/" + str(count) + " : " + str(elem.name)
|
||||
return str(id) + "/" + str(count) + " : " + str(elem.path)
|
||||
|
||||
|
||||
is_first_time_sleep = True
|
||||
|
||||
def wait_for_server_if_needed():
|
||||
global is_first_time_sleep
|
||||
if is_first_time_sleep == False:
|
||||
is_first_time_sleep = True;
|
||||
return
|
||||
if env.get_wait_between_sever_command() != 0:
|
||||
debug.info("Wait for server contrition (" + str(env.get_wait_between_sever_command()) + " s)")
|
||||
time.sleep(env.get_wait_between_sever_command())
|
||||
|
||||
|
||||
|
@@ -1,154 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
import os
|
||||
import sys
|
||||
import fnmatch
|
||||
# Local import
|
||||
from . import host
|
||||
from . import tools
|
||||
from . import debug
|
||||
from . import env
|
||||
is_init = False
|
||||
|
||||
"""
|
||||
def filter_name_and_file(root, list_files, filter):
|
||||
# filter elements:
|
||||
tmp_list = fnmatch.filter(list_files, filter)
|
||||
out = []
|
||||
for elem in tmp_list:
|
||||
if os.path.isfile(os.path.join(root, elem)) == True:
|
||||
out.append(elem);
|
||||
return out;
|
||||
|
||||
def filter_path(root, list_files):
|
||||
out = []
|
||||
for elem in list_files:
|
||||
if len(elem) == 0 \
|
||||
or elem[0] == '.':
|
||||
continue
|
||||
if os.path.isdir(os.path.join(root, elem)) == True:
|
||||
out.append(elem);
|
||||
return out;
|
||||
|
||||
def import_path_local(path, limit_sub_folder, exclude_path = [], base_name = ""):
|
||||
out = []
|
||||
debug.verbose("maestro files: " + str(path) + " [START]")
|
||||
if limit_sub_folder == 0:
|
||||
debug.debug("Subparsing limitation append ...")
|
||||
return []
|
||||
try:
|
||||
list_files = os.listdir(path)
|
||||
except:
|
||||
# an error occure, maybe read error ...
|
||||
debug.warning("error when getting subdirectory of '" + str(path) + "'")
|
||||
return []
|
||||
if path in exclude_path:
|
||||
debug.debug("find '" + str(path) + "' in exclude_path=" + str(exclude_path))
|
||||
return []
|
||||
# filter elements:
|
||||
tmp_list_maestro_file = filter_name_and_file(path, list_files, base_name + "*.py")
|
||||
debug.verbose("maestro files: " + str(path) + " : " + str(tmp_list_maestro_file))
|
||||
# Import the module:
|
||||
for filename in tmp_list_maestro_file:
|
||||
out.append(os.path.join(path, filename))
|
||||
debug.extreme_verbose(" Find a file : '" + str(out[-1]) + "'")
|
||||
need_parse_sub_folder = True
|
||||
rm_value = -1
|
||||
# check if we need to parse sub_folder
|
||||
if len(tmp_list_maestro_file) != 0:
|
||||
need_parse_sub_folder = False
|
||||
# check if the file "maestro_parse_sub.py" is present ==> parse SubFolder (force and add +1 in the resursing
|
||||
if base_name + "ParseSubFolders.txt" in list_files:
|
||||
debug.debug("find SubParser ... " + str(base_name + "ParseSubFolders.txt") + " " + path)
|
||||
data_file_sub = tools.file_read_data(os.path.join(path, base_name + "ParseSubFolders.txt"))
|
||||
if data_file_sub == "":
|
||||
debug.debug(" Empty file Load all subfolder in the worktree in '" + str(path) + "'")
|
||||
need_parse_sub_folder = True
|
||||
rm_value = 0
|
||||
else:
|
||||
list_sub = data_file_sub.split("\n")
|
||||
debug.debug(" Parse selected folders " + str(list_sub) + " no parse local folder directory")
|
||||
need_parse_sub_folder = False
|
||||
for folder in list_sub:
|
||||
if folder == "" \
|
||||
or folder == "/":
|
||||
continue;
|
||||
tmp_out = import_path_local(os.path.join(path, folder),
|
||||
1,
|
||||
exclude_path,
|
||||
base_name)
|
||||
# add all the elements:
|
||||
for elem in tmp_out:
|
||||
out.append(elem)
|
||||
if need_parse_sub_folder == True:
|
||||
list_folders = filter_path(path, list_files)
|
||||
for folder in list_folders:
|
||||
tmp_out = import_path_local(os.path.join(path, folder),
|
||||
limit_sub_folder - rm_value,
|
||||
exclude_path,
|
||||
base_name)
|
||||
# add all the elements:
|
||||
for elem in tmp_out:
|
||||
out.append(elem)
|
||||
return out
|
||||
"""
|
||||
|
||||
def init():
|
||||
global is_init;
|
||||
if is_init == True:
|
||||
return
|
||||
"""
|
||||
debug.verbose("Use Make as a make stadard")
|
||||
sys.path.append(tools.get_run_path())
|
||||
# create the list of basic folder:
|
||||
basic_folder_list = []
|
||||
basic_folder_list.append([tools.get_current_path(__file__), True])
|
||||
# Import all sub path without out and archive
|
||||
for elem_path in os.listdir("."):
|
||||
if os.path.isdir(elem_path) == False:
|
||||
continue
|
||||
if elem_path.lower() == "android" \
|
||||
or elem_path == "out" :
|
||||
continue
|
||||
debug.debug("Automatic load path: '" + elem_path + "'")
|
||||
basic_folder_list.append([elem_path, False])
|
||||
|
||||
# create in a single path the basic list of maestro files (all start with maestro and end with .py)
|
||||
exclude_path = env.get_exclude_search_path()
|
||||
limit_sub_folder = env.get_parse_depth()
|
||||
list_of_maestro_files = []
|
||||
for elem_path, is_system in basic_folder_list:
|
||||
if is_system == True:
|
||||
limit_sub_folder_tmp = 999999
|
||||
else:
|
||||
limit_sub_folder_tmp = limit_sub_folder
|
||||
tmp_out = import_path_local(elem_path,
|
||||
limit_sub_folder_tmp,
|
||||
exclude_path,
|
||||
env.get_build_system_base_name())
|
||||
# add all the elements:
|
||||
for elem in tmp_out:
|
||||
list_of_maestro_files.append(elem)
|
||||
|
||||
debug.debug("Files specific maestro: ")
|
||||
for elem_path in list_of_maestro_files:
|
||||
debug.debug(" " + elem_path)
|
||||
# simply import element from the basic list of files (single parse ...)
|
||||
builder.import_path(list_of_maestro_files)
|
||||
module.import_path(list_of_maestro_files)
|
||||
system.import_path(list_of_maestro_files)
|
||||
target.import_path(list_of_maestro_files)
|
||||
macro.import_path(list_of_maestro_files)
|
||||
|
||||
builder.init()
|
||||
"""
|
||||
is_init = True
|
||||
|
||||
|
378
maestro/arg.py
378
maestro/arg.py
@@ -1,378 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
import sys
|
||||
from . import debug
|
||||
|
||||
##
|
||||
## @brief Single argument class. It permit to define the getted argument.
|
||||
##
|
||||
class ArgElement:
|
||||
##
|
||||
## @brief Contructor.
|
||||
## @param[in] self Class handle
|
||||
## @param[in] option (string) Option name (write in fullmode ex: '--verbose' even if user write '-v')
|
||||
## @param[in] value (string) Writed value by the user (defult '')
|
||||
##
|
||||
def __init__(self, option, value=""):
|
||||
self.option = option;
|
||||
self.arg = value;
|
||||
|
||||
##
|
||||
## @brief Get the name of the argument: (write in fullmode ex: '--verbose' even if user write '-v')
|
||||
## @param[in] self Class handle
|
||||
## @return (string) The argument name
|
||||
##
|
||||
def get_option_name(self):
|
||||
return self.option
|
||||
|
||||
##
|
||||
## @brief Get argument data set by the user
|
||||
## @param[in] self Class handle
|
||||
## @return (string) The argument value
|
||||
##
|
||||
def get_arg(self):
|
||||
return self.arg
|
||||
|
||||
##
|
||||
## @brief Display the Argument property
|
||||
## @param[in] self Class handle
|
||||
##
|
||||
def display(self):
|
||||
if len(self.arg) == 0:
|
||||
debug.info("option : " + self.option)
|
||||
elif len(self.option) == 0:
|
||||
debug.info("element : " + self.arg)
|
||||
else:
|
||||
debug.info("option : " + self.option + ":" + self.arg)
|
||||
|
||||
##
|
||||
## @brief Declare a possibility of an argument value
|
||||
##
|
||||
class ArgDefine:
|
||||
##
|
||||
## @brief Contructor.
|
||||
## @param[in] self Class handle
|
||||
## @param[in] smallOption (char) Value for the small option ex: '-v' '-k' ... 1 single char element (no need of '-')
|
||||
## @param[in] bigOption (string) Value of the big option name ex: '--verbose' '--kill' ... stated with -- and with the full name (no need of '--')
|
||||
## @param[in] list ([[string,string],...]) Optionnal list of availlable option: '--mode=debug' ==> [['debug', 'debug mode'],['release', 'release the software']]
|
||||
## @param[in] desc (string) user friendly description with this parameter (default "")
|
||||
## @param[in] haveParam (bool) The option must have a parameter (default False)
|
||||
##
|
||||
def __init__(self,
|
||||
smallOption="", # like v for -v
|
||||
bigOption="", # like verbose for --verbose
|
||||
list=[], # ["val", "description"]
|
||||
desc="",
|
||||
haveParam=False):
|
||||
self.option_small = smallOption;
|
||||
self.option_big = bigOption;
|
||||
self.list = list;
|
||||
if len(self.list)!=0:
|
||||
self.have_param = True
|
||||
else:
|
||||
if True==haveParam:
|
||||
self.have_param = True
|
||||
else:
|
||||
self.have_param = False
|
||||
self.description = desc;
|
||||
|
||||
##
|
||||
## @brief Get the small name of the option ex: '-v'
|
||||
## @param[in] self Class handle
|
||||
## @return (string) Small name value
|
||||
##
|
||||
def get_option_small(self):
|
||||
return self.option_small
|
||||
|
||||
##
|
||||
## @brief Get the big name of the option ex: '--verbose'
|
||||
## @param[in] self Class handle
|
||||
## @return (string) Big name value
|
||||
##
|
||||
def get_option_big(self):
|
||||
return self.option_big
|
||||
|
||||
##
|
||||
## @brief Get the status of getting user parameter value
|
||||
## @param[in] self Class handle
|
||||
## @return True The user must write a value
|
||||
## @return False The user must NOT write a value
|
||||
##
|
||||
def need_parameters(self):
|
||||
return self.have_param
|
||||
|
||||
##
|
||||
## @brief Compatibility with @ref ArgSection class
|
||||
## @param[in] self Class handle
|
||||
## @return (string) empty string
|
||||
##
|
||||
def get_porperties(self):
|
||||
return ""
|
||||
|
||||
##
|
||||
## @brief Check if the user added value is correct or not with the list of availlable value
|
||||
## @param[in] self Class handle
|
||||
## @param[in] argument (string) User parameter value (string)
|
||||
## @return True The parameter is OK
|
||||
## @return False The parameter is NOT Availlable
|
||||
##
|
||||
def check_availlable(self, argument):
|
||||
if len(self.list)==0:
|
||||
return True
|
||||
for element,desc in self.list:
|
||||
if element == argument:
|
||||
return True
|
||||
return False
|
||||
|
||||
##
|
||||
## @brief Display the argument property when user request help
|
||||
## @param[in] self Class handle
|
||||
##
|
||||
def display(self):
|
||||
color = debug.get_color_set()
|
||||
if self.option_small != "" and self.option_big != "":
|
||||
print(" " + color['red'] + "-" + self.option_small + "" + color['default'] + " / " + color['red'] + "--" + self.option_big + color['default'])
|
||||
elif self.option_small != "":
|
||||
print(" " + color['red'] + "-" + self.option_small + color['default'])
|
||||
elif self.option_big != "":
|
||||
print(" " + color['red'] + "--" + self.option_big + color['default'])
|
||||
else:
|
||||
print(" ???? ==> internal error ...")
|
||||
if self.description != "":
|
||||
print(" " + self.description)
|
||||
if len(self.list)!=0:
|
||||
hasDescriptiveElement=False
|
||||
for val,desc in self.list:
|
||||
if desc!="":
|
||||
hasDescriptiveElement=True
|
||||
break;
|
||||
if hasDescriptiveElement==True:
|
||||
for val,desc in self.list:
|
||||
print(" " + val + " : " + desc)
|
||||
else:
|
||||
tmpElementPrint = ""
|
||||
for val,desc in self.list:
|
||||
if len(tmpElementPrint)!=0:
|
||||
tmpElementPrint += " / "
|
||||
tmpElementPrint += val
|
||||
print(" { " + tmpElementPrint + " }")
|
||||
|
||||
|
||||
##
|
||||
## @brief Section Class definition (permit to add a comment when requesting help
|
||||
##
|
||||
class ArgSection:
|
||||
##
|
||||
## @brief Constructor
|
||||
## @param[in] self Class handle
|
||||
## @param[in] sectionName (string) Name of the cestion ex: "option" is displayed [option]
|
||||
## @param[in] desc (string) Comment assiciated with the group
|
||||
##
|
||||
def __init__(self,
|
||||
sectionName="",
|
||||
desc=""):
|
||||
self.section = sectionName;
|
||||
self.description = desc;
|
||||
|
||||
##
|
||||
## @brief Compatibility with @ref ArgDefine class
|
||||
## @param[in] self Class handle
|
||||
## @return empty string
|
||||
##
|
||||
def get_option_small(self):
|
||||
return ""
|
||||
|
||||
##
|
||||
## @brief Compatibility with @ref ArgDefine class
|
||||
## @param[in] self Class handle
|
||||
## @return empty string
|
||||
##
|
||||
def get_option_big(self):
|
||||
return ""
|
||||
|
||||
##
|
||||
## @brief get property print value with the correct writing mode
|
||||
## @param[in] self Class handle
|
||||
## @return String to display in the short line help
|
||||
##
|
||||
def get_porperties(self):
|
||||
color = debug.get_color_set()
|
||||
return " [" + color['blue'] + self.section + color['default'] + "]"
|
||||
|
||||
##
|
||||
## @brief Display the argument property when user request help
|
||||
## @param[in] self Class handle
|
||||
##
|
||||
def display(self):
|
||||
color = debug.get_color_set()
|
||||
print(" [" + color['blue'] + self.section + color['default'] + "] : " + self.description)
|
||||
|
||||
|
||||
##
|
||||
## @brief Class to define the agmument list availlable for a program
|
||||
##
|
||||
class maestroArg:
|
||||
##
|
||||
## @brief Constructor.
|
||||
## @param[in] self Class handle
|
||||
##
|
||||
def __init__(self):
|
||||
self.list_properties = []
|
||||
|
||||
##
|
||||
## @brief Add a new argument possibilities...
|
||||
## @param[in] self Class handle
|
||||
## @param[in] smallOption (char) Value for the small option ex: '-v' '-k' ... 1 single char element (no need of '-')
|
||||
## @param[in] bigOption (string) Value of the big option name ex: '--verbose' '--kill' ... stated with -- and with the full name (no need of '--')
|
||||
## @param[in] list ([[string,string],...]) Optionnal list of availlable option: '--mode=debug' ==> [['debug', 'debug mode'],['release', 'release the software']]
|
||||
## @param[in] desc (string) user friendly description with this parameter (default "")
|
||||
## @param[in] haveParam (bool) The option must have a parameter (default False)
|
||||
##
|
||||
def add(self, smallOption="", bigOption="", list=[], desc="", haveParam=False):
|
||||
self.list_properties.append(ArgDefine(smallOption, bigOption, list, desc, haveParam))
|
||||
|
||||
##
|
||||
## @brief Add section on argument list
|
||||
## @param[in] self Class handle
|
||||
## @param[in] sectionName (string) Name of the cestion ex: "option" is displayed [option]
|
||||
## @param[in] sectionDesc (string) Comment assiciated with the group
|
||||
##
|
||||
def add_section(self, sectionName, sectionDesc):
|
||||
self.list_properties.append(ArgSection(sectionName, sectionDesc))
|
||||
|
||||
##
|
||||
## @brief Parse the argument set in the command line
|
||||
## @param[in] self Class handle
|
||||
##
|
||||
def parse(self):
|
||||
listArgument = [] # composed of list element
|
||||
NotparseNextElement=False
|
||||
for iii in range(1, len(sys.argv)):
|
||||
# special case of parameter in some elements
|
||||
if NotparseNextElement==True:
|
||||
NotparseNextElement = False
|
||||
continue
|
||||
debug.verbose("parse [" + str(iii) + "]=" + sys.argv[iii])
|
||||
argument = sys.argv[iii]
|
||||
optionList = argument.split("=")
|
||||
debug.verbose(str(optionList))
|
||||
if type(optionList) == type(str()):
|
||||
option = optionList
|
||||
else:
|
||||
option = optionList[0]
|
||||
optionParam = argument[len(option)+1:]
|
||||
debug.verbose(option)
|
||||
argumentFound=False;
|
||||
if option[:2]=="--":
|
||||
# big argument
|
||||
for prop in self.list_properties:
|
||||
if prop.get_option_big()=="":
|
||||
continue
|
||||
if prop.get_option_big() == option[2:]:
|
||||
# find it
|
||||
debug.verbose("find argument 2 : " + option[2:])
|
||||
if prop.need_parameters()==True:
|
||||
internalSub = option[2+len(prop.get_option_big()):]
|
||||
if len(internalSub)!=0:
|
||||
if len(optionParam)!=0:
|
||||
# wrong argument ...
|
||||
debug.warning("maybe wrong argument for : '" + prop.get_option_big() + "' cmdLine='" + argument + "'")
|
||||
prop.display()
|
||||
continue
|
||||
optionParam = internalSub
|
||||
if len(optionParam)==0:
|
||||
#Get the next parameters
|
||||
if len(sys.argv) > iii+1:
|
||||
optionParam = sys.argv[iii+1]
|
||||
NotparseNextElement=True
|
||||
else :
|
||||
# missing arguments
|
||||
debug.warning("parsing argument error : '" + prop.get_option_big() + "' Missing : subParameters ... cmdLine='" + argument + "'")
|
||||
prop.display()
|
||||
exit(-1)
|
||||
if prop.check_availlable(optionParam)==False:
|
||||
debug.warning("argument error : '" + prop.get_option_big() + "' SubParameters not availlable ... cmdLine='" + argument + "' option='" + optionParam + "'")
|
||||
prop.display()
|
||||
exit(-1)
|
||||
listArgument.append(ArgElement(prop.get_option_big(),optionParam))
|
||||
argumentFound = True
|
||||
else:
|
||||
if len(optionParam)!=0:
|
||||
debug.warning("parsing argument error : '" + prop.get_option_big() + "' need no subParameters : '" + optionParam + "' cmdLine='" + argument + "'")
|
||||
prop.display()
|
||||
listArgument.append(ArgElement(prop.get_option_big()))
|
||||
argumentFound = True
|
||||
break;
|
||||
if False==argumentFound:
|
||||
debug.error("UNKNOW argument : '" + argument + "'")
|
||||
elif option[:1]=="-":
|
||||
# small argument
|
||||
for prop in self.list_properties:
|
||||
if prop.get_option_small()=="":
|
||||
continue
|
||||
if prop.get_option_small() == option[1:1+len(prop.get_option_small())]:
|
||||
# find it
|
||||
debug.verbose("find argument 1 : " + option[1:1+len(prop.get_option_small())])
|
||||
if prop.need_parameters()==True:
|
||||
internalSub = option[1+len(prop.get_option_small()):]
|
||||
if len(internalSub)!=0:
|
||||
if len(optionParam)!=0:
|
||||
# wrong argument ...
|
||||
debug.warning("maybe wrong argument for : '" + prop.get_option_big() + "' cmdLine='" + argument + "'")
|
||||
prop.display()
|
||||
continue
|
||||
optionParam = internalSub
|
||||
if len(optionParam)==0:
|
||||
#Get the next parameters
|
||||
if len(sys.argv) > iii+1:
|
||||
optionParam = sys.argv[iii+1]
|
||||
NotparseNextElement=True
|
||||
else :
|
||||
# missing arguments
|
||||
debug.warning("parsing argument error : '" + prop.get_option_big() + "' Missing : subParameters cmdLine='" + argument + "'")
|
||||
prop.display()
|
||||
exit(-1)
|
||||
if prop.check_availlable(optionParam)==False:
|
||||
debug.warning("argument error : '" + prop.get_option_big() + "' SubParameters not availlable ... cmdLine='" + argument + "' option='" + optionParam + "'")
|
||||
prop.display()
|
||||
exit(-1)
|
||||
listArgument.append(ArgElement(prop.get_option_big(),optionParam))
|
||||
argumentFound = True
|
||||
else:
|
||||
if len(optionParam)!=0:
|
||||
debug.warning("parsing argument error : '" + prop.get_option_big() + "' need no subParameters : '" + optionParam + "' cmdLine='" + argument + "'")
|
||||
prop.display()
|
||||
listArgument.append(ArgElement(prop.get_option_big()))
|
||||
argumentFound = True
|
||||
break;
|
||||
|
||||
if argumentFound==False:
|
||||
#unknow element ... ==> just add in the list ...
|
||||
debug.verbose("unknow argument : " + argument)
|
||||
listArgument.append(ArgElement("", argument))
|
||||
|
||||
#for argument in listArgument:
|
||||
# argument.display()
|
||||
#exit(0)
|
||||
return listArgument;
|
||||
|
||||
##
|
||||
## @brief Display help on console output
|
||||
## @param[in] self Class handle
|
||||
##
|
||||
def display(self):
|
||||
print("usage:")
|
||||
listOfPropertiesArg = "";
|
||||
for element in self.list_properties :
|
||||
listOfPropertiesArg += element.get_porperties()
|
||||
print(" " + sys.argv[0] + listOfPropertiesArg + " ...")
|
||||
for element in self.list_properties :
|
||||
element.display()
|
||||
|
258
maestro/debug.py
258
maestro/debug.py
@@ -1,258 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
|
||||
import os
|
||||
import threading
|
||||
import re
|
||||
|
||||
debug_level=3
|
||||
debug_color=False
|
||||
|
||||
color_default= ""
|
||||
color_red = ""
|
||||
color_green = ""
|
||||
color_yellow = ""
|
||||
color_blue = ""
|
||||
color_purple = ""
|
||||
color_cyan = ""
|
||||
|
||||
|
||||
debug_lock = threading.Lock()
|
||||
|
||||
##
|
||||
## @brief Set log level of the console log system
|
||||
## @param[in] id (int) Value of the log level:
|
||||
## 0: None
|
||||
## 1: error
|
||||
## 2: warning
|
||||
## 3: info
|
||||
## 4: debug
|
||||
## 5: verbose
|
||||
## 6: extreme_verbose
|
||||
##
|
||||
def set_level(id):
|
||||
global debug_level
|
||||
debug_level = id
|
||||
#print "SetDebug level at " + str(debug_level)
|
||||
|
||||
##
|
||||
## @brief Get the current debug leval
|
||||
## @return The value of the log level. Show: @ref set_level
|
||||
##
|
||||
def get_level():
|
||||
global debug_level
|
||||
return debug_level
|
||||
|
||||
##
|
||||
## @brief Enable color of the console Log system
|
||||
##
|
||||
def enable_color():
|
||||
global debug_color
|
||||
debug_color = True
|
||||
global color_default
|
||||
color_default= "\033[00m"
|
||||
global color_red
|
||||
color_red = "\033[31m"
|
||||
global color_green
|
||||
color_green = "\033[32m"
|
||||
global color_yellow
|
||||
color_yellow = "\033[33m"
|
||||
global color_blue
|
||||
color_blue = "\033[01;34m"
|
||||
global color_purple
|
||||
color_purple = "\033[35m"
|
||||
global color_cyan
|
||||
color_cyan = "\033[36m"
|
||||
|
||||
##
|
||||
## @brief Disable color of the console Log system
|
||||
##
|
||||
def disable_color():
|
||||
global debug_color
|
||||
debug_color = True
|
||||
global color_default
|
||||
color_default= ""
|
||||
global color_red
|
||||
color_red = ""
|
||||
global color_green
|
||||
color_green = ""
|
||||
global color_yellow
|
||||
color_yellow = ""
|
||||
global color_blue
|
||||
color_blue = ""
|
||||
global color_purple
|
||||
color_purple = ""
|
||||
global color_cyan
|
||||
color_cyan = ""
|
||||
|
||||
##
|
||||
## @brief Print a extreme verbose log
|
||||
## @param[in] input (string) Value to print if level is enough
|
||||
## @param[in] force (bool) force display (no check of log level)
|
||||
##
|
||||
def extreme_verbose(input, force=False):
|
||||
global debug_lock
|
||||
global debug_level
|
||||
if debug_level >= 6 \
|
||||
or force == True:
|
||||
debug_lock.acquire()
|
||||
print(color_blue + input + color_default)
|
||||
debug_lock.release()
|
||||
|
||||
##
|
||||
## @brief Print a verbose log
|
||||
## @param[in] input (string) Value to print if level is enough
|
||||
## @param[in] force (bool) force display (no check of log level)
|
||||
##
|
||||
def verbose(input, force=False):
|
||||
global debug_lock
|
||||
global debug_level
|
||||
if debug_level >= 5 \
|
||||
or force == True:
|
||||
debug_lock.acquire()
|
||||
print(color_blue + input + color_default)
|
||||
debug_lock.release()
|
||||
|
||||
##
|
||||
## @brief Print a debug log
|
||||
## @param[in] input (string) Value to print if level is enough
|
||||
## @param[in] force (bool) force display (no check of log level)
|
||||
##
|
||||
def debug(input, force=False):
|
||||
global debug_lock
|
||||
global debug_level
|
||||
if debug_level >= 4 \
|
||||
or force == True:
|
||||
debug_lock.acquire()
|
||||
print(color_green + input + color_default)
|
||||
debug_lock.release()
|
||||
|
||||
##
|
||||
## @brief Print an info log
|
||||
## @param[in] input (string) Value to print if level is enough
|
||||
## @param[in] force (bool) force display (no check of log level)
|
||||
##
|
||||
def info(input, force=False):
|
||||
global debug_lock
|
||||
global debug_level
|
||||
if debug_level >= 3 \
|
||||
or force == True:
|
||||
debug_lock.acquire()
|
||||
print(input + color_default)
|
||||
debug_lock.release()
|
||||
|
||||
##
|
||||
## @brief Print a warning log
|
||||
## @param[in] input (string) Value to print if level is enough
|
||||
## @param[in] force (bool) force display (no check of log level)
|
||||
##
|
||||
def warning(input, force=False):
|
||||
global debug_lock
|
||||
global debug_level
|
||||
if debug_level >= 2 \
|
||||
or force == True:
|
||||
debug_lock.acquire()
|
||||
print(color_purple + "[WARNING] " + input + color_default)
|
||||
debug_lock.release()
|
||||
|
||||
##
|
||||
## @brief Print a todo log
|
||||
## @param[in] input (string) Value to print if level is enough
|
||||
## @param[in] force (bool) force display (no check of log level)
|
||||
##
|
||||
def todo(input, force=False):
|
||||
global debug_lock
|
||||
global debug_level
|
||||
if debug_level >= 3 \
|
||||
or force == True:
|
||||
debug_lock.acquire()
|
||||
print(color_purple + "[TODO] " + input + color_default)
|
||||
debug_lock.release()
|
||||
|
||||
##
|
||||
## @brief Print an error log
|
||||
## @param[in] input (string) Value to print if level is enough
|
||||
## @param[in] thread_id (int) Current thead ID of the builder thread
|
||||
## @param[in] force (bool) force display (no check of log level)
|
||||
## @param[in] crash (bool) build error has appear ==> request stop of all builds
|
||||
##
|
||||
def error(input, thread_id=-1, force=False, crash=True):
|
||||
global debug_lock
|
||||
global debug_level
|
||||
if debug_level >= 1 \
|
||||
or force == True:
|
||||
debug_lock.acquire()
|
||||
print(color_red + "[ERROR] " + input + color_default)
|
||||
debug_lock.release()
|
||||
if crash == True:
|
||||
exit(-1)
|
||||
#os_exit(-1)
|
||||
#raise "error happend"
|
||||
|
||||
|
||||
##
|
||||
## @brief Print a log for a specific element action like generateing .so or binary ...
|
||||
## @param[in] type (string) type of action. Like: "copy file", "StaticLib", "Prebuild", "Library" ...
|
||||
## @param[in] lib (string) Name of the library/binary/package that action is done
|
||||
## @param[in] dir (string) build direction. ex: "<==", "==>" ...
|
||||
## @param[in] name (string) Destination of the data
|
||||
## @param[in] force (bool) force display (no check of log level)
|
||||
##
|
||||
def print_element(type, lib, dir, name, force=False):
|
||||
global debug_lock
|
||||
global debug_level
|
||||
if debug_level >= 3 \
|
||||
or force == True:
|
||||
debug_lock.acquire()
|
||||
print(color_cyan + type + color_default + " : " + color_yellow + lib + color_default + " " + dir + " " + color_blue + name + color_default)
|
||||
debug_lock.release()
|
||||
|
||||
##
|
||||
## @brief Print a compilation return (output)
|
||||
## @param[in] my_string (string) Std-error/std-info that is generate by the build system
|
||||
##
|
||||
def print_compilator(my_string):
|
||||
global debug_color
|
||||
global debug_lock
|
||||
if debug_color == True:
|
||||
my_string = my_string.replace('\\n', '\n')
|
||||
my_string = my_string.replace('\\t', '\t')
|
||||
my_string = my_string.replace('error:', color_red+'error:'+color_default)
|
||||
my_string = my_string.replace('warning:', color_purple+'warning:'+color_default)
|
||||
my_string = my_string.replace('note:', color_green+'note:'+color_default)
|
||||
my_string = re.sub(r'([/\w_-]+\.\w+):', r'-COLORIN-\1-COLOROUT-:', my_string)
|
||||
my_string = my_string.replace('-COLORIN-', color_yellow)
|
||||
my_string = my_string.replace('-COLOROUT-', color_default)
|
||||
|
||||
debug_lock.acquire()
|
||||
print(my_string)
|
||||
debug_lock.release()
|
||||
|
||||
##
|
||||
## @brief Get the list of default color
|
||||
## @return A map with keys: "default","red","green","yellow","blue","purple","cyan"
|
||||
##
|
||||
def get_color_set() :
|
||||
global color_default
|
||||
global color_red
|
||||
global color_green
|
||||
global color_yellow
|
||||
global color_blue
|
||||
global color_purple
|
||||
global color_cyan
|
||||
return {
|
||||
"default": color_default,
|
||||
"red": color_red,
|
||||
"green": color_green,
|
||||
"yellow": color_yellow,
|
||||
"blue": color_blue,
|
||||
"purple": color_purple,
|
||||
"cyan": color_cyan,
|
||||
}
|
@@ -1,88 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
|
||||
# Local import
|
||||
from . import debug
|
||||
|
||||
|
||||
|
||||
force_mode=False
|
||||
|
||||
def set_force_mode(val):
|
||||
global force_mode
|
||||
if val==1:
|
||||
force_mode = 1
|
||||
else:
|
||||
force_mode = 0
|
||||
|
||||
def get_force_mode():
|
||||
global force_mode
|
||||
return force_mode
|
||||
|
||||
force_optimisation=False
|
||||
|
||||
def set_force_optimisation(val):
|
||||
global force_optimisation
|
||||
if val==1:
|
||||
force_optimisation = 1
|
||||
else:
|
||||
force_optimisation = 0
|
||||
|
||||
def get_force_optimisation():
|
||||
global force_optimisation
|
||||
return force_optimisation
|
||||
|
||||
isolate_system=False
|
||||
|
||||
def set_isolate_system(val):
|
||||
global isolate_system
|
||||
if val==1:
|
||||
isolate_system = 1
|
||||
else:
|
||||
isolate_system = 0
|
||||
|
||||
def get_isolate_system():
|
||||
global isolate_system
|
||||
return isolate_system
|
||||
|
||||
parse_depth = 9999999
|
||||
|
||||
def set_parse_depth(val):
|
||||
global parse_depth
|
||||
parse_depth = val
|
||||
debug.debug("Set depth search element: " + str(parse_depth))
|
||||
|
||||
def get_parse_depth():
|
||||
global parse_depth
|
||||
return parse_depth
|
||||
|
||||
exclude_search_path = []
|
||||
|
||||
def set_exclude_search_path(val):
|
||||
global exclude_search_path
|
||||
exclude_search_path = val
|
||||
debug.debug("Set depth search element: " + str(exclude_search_path))
|
||||
|
||||
def get_exclude_search_path():
|
||||
global exclude_search_path
|
||||
return exclude_search_path
|
||||
|
||||
|
||||
system_base_name = "maestro"
|
||||
|
||||
def set_system_base_name(val):
|
||||
global system_base_name
|
||||
system_base_name = val
|
||||
debug.debug("Set basename: '" + str(system_base_name) + "'")
|
||||
|
||||
def get_system_base_name():
|
||||
global system_base_name
|
||||
return system_base_name
|
||||
|
@@ -1,303 +0,0 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
##
|
||||
## @author Edouard DUPIN
|
||||
##
|
||||
## @copyright 2012, Edouard DUPIN, all right reserved
|
||||
##
|
||||
## @license MPL v2.0 (see license file)
|
||||
##
|
||||
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import sys
|
||||
if sys.version_info >= (3, 0):
|
||||
import queue
|
||||
else:
|
||||
import Queue as queue
|
||||
import os
|
||||
import subprocess
|
||||
import shlex
|
||||
# Local import
|
||||
from . import debug
|
||||
from . import tools
|
||||
from . import env
|
||||
from . import depend
|
||||
|
||||
queue_lock = threading.Lock()
|
||||
work_queue = queue.Queue()
|
||||
current_thread_working = 0
|
||||
threads = []
|
||||
# To know the first error arrive in the pool ==> to display all the time the same error file when multiple compilation
|
||||
current_id_execution = 0
|
||||
error_execution = {
|
||||
"id":-1,
|
||||
"cmd":"",
|
||||
"return":0,
|
||||
"err":"",
|
||||
"out":"",
|
||||
}
|
||||
|
||||
exit_flag = False # resuest stop of the thread
|
||||
is_init = False # the thread are initialized
|
||||
error_occured = False # a thread have an error
|
||||
processor_availlable = 1 # number of CPU core availlable
|
||||
##
|
||||
## @brief Execute the command with no get of output
|
||||
##
|
||||
def run_command_no_lock_out(cmd_line):
|
||||
# prepare command line:
|
||||
args = shlex.split(cmd_line)
|
||||
debug.info("cmd = " + str(args))
|
||||
try:
|
||||
# create the subprocess
|
||||
p = subprocess.Popen(args)
|
||||
except subprocess.CalledProcessError as e:
|
||||
debug.error("subprocess.CalledProcessError : " + str(args))
|
||||
return
|
||||
#except:
|
||||
# debug.error("Exception on : " + str(args))
|
||||
# launch the subprocess:
|
||||
p.communicate()
|
||||
|
||||
##
|
||||
## @brief Execute the command and ruturn generate data
|
||||
##
|
||||
def run_command_direct(cmd_line):
|
||||
# prepare command line:
|
||||
args = shlex.split(cmd_line)
|
||||
debug.verbose("cmd = " + str(args))
|
||||
try:
|
||||
# create the subprocess
|
||||
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
except subprocess.CalledProcessError as e:
|
||||
debug.error("subprocess.CalledProcessError : " + str(args))
|
||||
except:
|
||||
debug.error("Exception on : " + str(args))
|
||||
# launch the subprocess:
|
||||
output, err = p.communicate()
|
||||
if sys.version_info >= (3, 0):
|
||||
output = output.decode("utf-8")
|
||||
err = err.decode("utf-8")
|
||||
# Check error :
|
||||
if p.returncode == 0:
|
||||
if output == None:
|
||||
return err[:-1];
|
||||
return output[:-1];
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def run_command(cmd_line, store_cmd_line="", build_id=-1, file="", store_output_file="", depend_data=None):
|
||||
global error_occured
|
||||
global exit_flag
|
||||
global current_id_execution
|
||||
global error_execution
|
||||
# prepare command line:
|
||||
args = shlex.split(cmd_line)
|
||||
debug.verbose("cmd = " + str(args))
|
||||
try:
|
||||
# create the subprocess
|
||||
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
except subprocess.CalledProcessError as e:
|
||||
debug.error("subprocess.CalledProcessError : TODO ...")
|
||||
except:
|
||||
debug.error("Exception on : " + str(args))
|
||||
# launch the subprocess:
|
||||
output, err = p.communicate()
|
||||
if sys.version_info >= (3, 0):
|
||||
output = output.decode("utf-8")
|
||||
err = err.decode("utf-8")
|
||||
# store error if needed:
|
||||
tools.store_warning(store_output_file, output, err)
|
||||
# Check error :
|
||||
if p.returncode == 0:
|
||||
debug.debug(env.print_pretty(cmd_line))
|
||||
queue_lock.acquire()
|
||||
if depend_data != None:
|
||||
depend.create_dependency_file(depend_data['file'], depend_data['data'])
|
||||
# TODO : Print the output all the time .... ==> to show warnings ...
|
||||
if build_id >= 0 and (output != "" or err != ""):
|
||||
debug.warning("output in subprocess compiling: '" + file + "'")
|
||||
if output != "":
|
||||
debug.print_compilator(output)
|
||||
if err != "":
|
||||
debug.print_compilator(err)
|
||||
queue_lock.release()
|
||||
else:
|
||||
error_occured = True
|
||||
exit_flag = True
|
||||
# if No ID : Not in a multiprocess mode ==> just stop here
|
||||
if build_id < 0:
|
||||
debug.debug(env.print_pretty(cmd_line), force=True)
|
||||
debug.print_compilator(output)
|
||||
debug.print_compilator(err)
|
||||
if p.returncode == 2:
|
||||
debug.error("can not compile file ... [keyboard interrrupt]")
|
||||
else:
|
||||
debug.error("can not compile file ... ret : " + str(p.returncode))
|
||||
else:
|
||||
# in multiprocess interface
|
||||
queue_lock.acquire()
|
||||
# if an other write an error before, check if the current process is started before ==> then is the first error
|
||||
if error_execution["id"] >= build_id:
|
||||
# nothing to do ...
|
||||
queue_lock.release()
|
||||
return;
|
||||
error_execution["id"] = build_id
|
||||
error_execution["cmd"] = cmd_line
|
||||
error_execution["return"] = p.returncode
|
||||
error_execution["err"] = err,
|
||||
error_execution["out"] = output,
|
||||
queue_lock.release()
|
||||
# not write the command file...
|
||||
return
|
||||
debug.verbose("done 3")
|
||||
# write cmd line only after to prevent errors ...
|
||||
tools.store_command(cmd_line, store_cmd_line)
|
||||
|
||||
|
||||
|
||||
class myThread(threading.Thread):
|
||||
def __init__(self, thread_id, lock, queue):
|
||||
threading.Thread.__init__(self)
|
||||
self.thread_id = thread_id
|
||||
self.name = "Thread " + str(thread_id)
|
||||
self.queue = queue
|
||||
self.lock = lock
|
||||
def run(self):
|
||||
debug.verbose("Starting " + self.name)
|
||||
global exit_flag
|
||||
global current_thread_working
|
||||
working_set = False
|
||||
while exit_flag == False:
|
||||
self.lock.acquire()
|
||||
if not self.queue.empty():
|
||||
if working_set == False:
|
||||
current_thread_working += 1
|
||||
working_set = True
|
||||
data = self.queue.get()
|
||||
self.lock.release()
|
||||
debug.verbose(self.name + " processing '" + data[0] + "'")
|
||||
if data[0]=="cmd_line":
|
||||
comment = data[2]
|
||||
cmd_line = data[1]
|
||||
cmd_store_file = data[3]
|
||||
debug.print_element("[" + str(data[4]) + "][" + str(self.thread_id) + "] " + comment[0],
|
||||
comment[1],
|
||||
comment[2],
|
||||
comment[3])
|
||||
run_command(cmd_line,
|
||||
cmd_store_file,
|
||||
build_id=data[4],
|
||||
file=comment[3],
|
||||
store_output_file=data[5],
|
||||
depend_data=data[6])
|
||||
else:
|
||||
debug.warning("unknow request command : " + data[0])
|
||||
else:
|
||||
if working_set==True:
|
||||
current_thread_working -= 1
|
||||
working_set=False
|
||||
# no element to parse, just wait ...
|
||||
self.lock.release()
|
||||
time.sleep(0.2)
|
||||
# kill requested ...
|
||||
debug.verbose("Exiting " + self.name)
|
||||
|
||||
|
||||
def set_error_occured():
|
||||
global exit_flag
|
||||
exit_flag = True
|
||||
|
||||
def set_core_number(number_of_core):
|
||||
global processor_availlable
|
||||
processor_availlable = number_of_core
|
||||
debug.debug(" set number of core for multi process compilation : " + str(processor_availlable))
|
||||
# nothing else to do
|
||||
|
||||
def init():
|
||||
global error_occured
|
||||
global exit_flag
|
||||
global is_init
|
||||
if is_init == False:
|
||||
is_init = True
|
||||
error_occured = False
|
||||
global threads
|
||||
global queue_lock
|
||||
global work_queue
|
||||
# Create all the new threads
|
||||
thread_id = 0
|
||||
while thread_id < processor_availlable:
|
||||
thread = myThread(thread_id, queue_lock, work_queue)
|
||||
thread.start()
|
||||
threads.append(thread)
|
||||
thread_id += 1
|
||||
|
||||
|
||||
|
||||
def un_init():
|
||||
global exit_flag
|
||||
# Notify threads it's time to exit
|
||||
exit_flag = True
|
||||
if processor_availlable > 1:
|
||||
# Wait for all threads to complete
|
||||
for tmp in threads:
|
||||
debug.verbose("join thread ...")
|
||||
tmp.join()
|
||||
debug.verbose("Exiting ALL Threads")
|
||||
|
||||
|
||||
|
||||
def run_in_pool(cmd_line, comment, store_cmd_line="", store_output_file="", depend_data=None):
|
||||
global current_id_execution
|
||||
if processor_availlable <= 1:
|
||||
debug.print_element(comment[0], comment[1], comment[2], comment[3])
|
||||
run_command(cmd_line, store_cmd_line, file=comment[3], store_output_file=store_output_file, depend_data=depend_data)
|
||||
return
|
||||
# multithreaded mode
|
||||
init()
|
||||
# Fill the queue
|
||||
queue_lock.acquire()
|
||||
debug.verbose("add : in pool cmd_line")
|
||||
work_queue.put(["cmd_line", cmd_line, comment, store_cmd_line, current_id_execution, store_output_file, depend_data])
|
||||
current_id_execution +=1;
|
||||
queue_lock.release()
|
||||
|
||||
|
||||
def pool_synchrosize():
|
||||
global error_occured
|
||||
global error_execution
|
||||
if processor_availlable <= 1:
|
||||
#in this case : nothing to synchronise
|
||||
return
|
||||
|
||||
debug.verbose("wait queue process ended\n")
|
||||
# Wait for queue to empty
|
||||
while not work_queue.empty() \
|
||||
and error_occured == False:
|
||||
time.sleep(0.2)
|
||||
pass
|
||||
# Wait all thread have ended their current process
|
||||
while current_thread_working != 0 \
|
||||
and error_occured == False:
|
||||
time.sleep(0.2)
|
||||
pass
|
||||
if error_occured == False:
|
||||
debug.verbose("queue is empty")
|
||||
else:
|
||||
un_init()
|
||||
debug.debug("Thread return with error ... ==> stop all the pool")
|
||||
if error_execution["id"] == -1:
|
||||
debug.error("Pool error occured ... (No return information on Pool)")
|
||||
return
|
||||
debug.error("Error in an pool element : [" + str(error_execution["id"]) + "]", crash=False)
|
||||
debug.debug(env.print_pretty(error_execution["cmd"]), force=True)
|
||||
debug.print_compilator(str(error_execution["out"][0]))
|
||||
debug.print_compilator(str(error_execution["err"][0]))
|
||||
if error_execution["return"] == 2:
|
||||
debug.error("can not compile file ... [keyboard interrrupt]")
|
||||
else:
|
||||
debug.error("can not compile file ... return value : " + str(error_execution["return"]))
|
||||
|
24
setup.py
24
setup.py
@@ -15,15 +15,16 @@ def readme():
|
||||
return f.read()
|
||||
|
||||
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
|
||||
setup(name='maestro',
|
||||
version='0.1.0',
|
||||
description='Maestro generic source manager (like repo in simple mode)',
|
||||
setup(name='island',
|
||||
version='0.9.0',
|
||||
description='island generic source manager (like repo in simple mode)',
|
||||
long_description=readme(),
|
||||
url='http://github.com/HeeroYui/maestro',
|
||||
url='http://github.com/HeeroYui/island',
|
||||
author='Edouard DUPIN',
|
||||
author_email='yui.heero@gmail.com',
|
||||
license='MPL-2',
|
||||
packages=['maestro'],
|
||||
packages=['island',
|
||||
'island/actions'],
|
||||
classifiers=[
|
||||
'Development Status :: 2 - Pre-Alpha',
|
||||
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
|
||||
@@ -31,15 +32,24 @@ setup(name='maestro',
|
||||
'Topic :: Software Development :: Build Tools'
|
||||
],
|
||||
keywords='source manager repo qisrc lutin',
|
||||
scripts=['bin/maestro'],
|
||||
scripts=['bin/island'],
|
||||
# Does not work on MacOs
|
||||
#data_file=[
|
||||
# ('/etc/bash_completion.d', ['bash-autocompletion/lutin']),
|
||||
#],
|
||||
install_requires=[
|
||||
'lxml',
|
||||
'realog',
|
||||
'death',
|
||||
],
|
||||
include_package_data = True,
|
||||
zip_safe=False)
|
||||
|
||||
#To developp: sudo ./setup.py install
|
||||
# sudo ./setup.py develop
|
||||
#TO register all in pip: ./setup.py register sdist upload
|
||||
#TO register all in pip: use external tools:
|
||||
# pip install twine
|
||||
# # create the archive
|
||||
# ./setup.py sdist
|
||||
# twine upload dist/*
|
||||
|
||||
|
Reference in New Issue
Block a user