def update(silent=False, **kwargs):
"""
Update Contiki-OS and RPL Attacks Framework.
:param silent: run command silently
:param kwargs: simulation keyword arguments (see the documentation for more information)
"""
for folder, repository in zip([CONTIKI_FOLDER, FRAMEWORK_FOLDER], ["Contiki-OS", "RPL Attacks Framework"]):
with hide(*HIDDEN_ALL):
with lcd(folder):
if "Could not resolve proxy" in local('git fetch --all', capture=True):
logger.error("Update failed ; please check your proxy settings")
break
uptodate = "branch is up-to-date" in local('git checkout master', capture=True).strip().split('\n')[-1]
if not uptodate:
req_exists = exists("requirements.txt")
if req_exists:
req_md5 = hash_file("requirements.txt")
logger.warn("You are about to loose any custom change made to {} ;".format(repository))
if silent or std_input("Proceed anyway ? (yes|no) [default: no] ", 'yellow') == 'yes':
local('git submodule update --init')
local('git fetch --all')
local('git reset --hard origin/master')
local('git pull')
if req_exists and hash_file("requirements.txt") != req_md5:
local('pip install -r requirements.txt')
if repository == "RPL Attacks Framework":
remove_files(folder, "Vagrantfile")
remove_folder(join(folder, "provisioning"))
logger.debug(" > {} {}".format(repository, ["updated", "already up-to-date"][uptodate]))
if not silent:
logger.warn("Restarting the framework...")
restart(PIDFILE)
评论列表
文章目录