[DEV] add a volatile repository concept
This commit is contained in:
parent
3f51e9e35c
commit
bd7f732ca2
82
island/actions/islandAction_volatile-add.py
Normal file
82
island/actions/islandAction_volatile-add.py
Normal file
@ -0,0 +1,82 @@
|
||||
#!/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
|
||||
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 + "'")
|
||||
|
||||
# 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
|
||||
|
||||
|
48
island/actions/islandAction_volatile-list.py
Normal file
48
island/actions/islandAction_volatile-list.py
Normal file
@ -0,0 +1,48 @@
|
||||
#!/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
|
||||
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() + "'")
|
||||
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
|
||||
|
||||
|
@ -11,6 +11,7 @@ import platform
|
||||
import sys
|
||||
import os
|
||||
import copy
|
||||
import json
|
||||
# Local import
|
||||
from realog import debug
|
||||
from . import tools
|
||||
@ -26,9 +27,8 @@ class Config():
|
||||
self._repo = ""
|
||||
self._branch = "master"
|
||||
self._manifest_name = "default.xml"
|
||||
|
||||
self._volatiles = []
|
||||
self.load()
|
||||
|
||||
|
||||
# set it deprecated at 2020/07
|
||||
def load_old(self):
|
||||
@ -70,6 +70,10 @@ class Config():
|
||||
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"])
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -78,6 +82,7 @@ class Config():
|
||||
data["repo"] = self._repo
|
||||
data["branch"] = self._branch
|
||||
data["manifest_name"] = self._manifest_name
|
||||
data["volatiles"] = self._volatiles
|
||||
with open(env.get_island_path_config(), 'w') as outfile:
|
||||
json.dump(data, outfile, indent=4)
|
||||
return True
|
||||
@ -100,4 +105,18 @@ class Config():
|
||||
|
||||
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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user