代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/Beremiz 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
from functools import wraps
import click
import fake_wx
from ProjectController import ProjectController
from LocalRuntimeMixin import LocalRuntimeMixin
class Log:
def __init__(self):
self.crlfpending = False
def write(self, s):
if s:
if self.crlfpending:
sys.stdout.write("\n")
sys.stdout.write(s)
self.crlfpending = 0
def write_error(self, s):
if s:
self.write("Error: "+s)
def write_warning(self, s):
if s:
self.write("Warning: "+s)
def flush(self):
sys.stdout.flush()
def isatty(self):
return False
def progress(self, s):
if s:
sys.stdout.write(s+"\r")
self.crlfpending = True
def with_project_loaded(func):
@wraps(func)
def func_wrapper(self, *args, **kwargs):
if not self.HasOpenedProject():
if self.check_and_load_project():
return 1
self.apply_config()
return func(self, *args, **kwargs)
return func_wrapper
def connected(func):
@wraps(func)
def func_wrapper(self, *args, **kwargs):
if self._connector is None:
if self.session.uri:
self.BeremizRoot.setURI_location(self.session.uri)
if not self._Connect():
return 1
return func(self, *args, **kwargs)
return func_wrapper
class CLIController(LocalRuntimeMixin, ProjectController):
def __init__(self, session):
self.session = session
log = Log()
LocalRuntimeMixin.__init__(self, log)
ProjectController.__init__(self, None, log)
def check_and_load_project(self):
if not os.path.isdir(self.session.project_home):
self.logger.write_error(
_("\"%s\" is not a valid Beremiz project\n") % self.session.project_home)
return True
errmsg, error = self.LoadProject(self.session.project_home, self.session.buildpath)
if error:
self.logger.write_error(errmsg)
return True
def apply_config(self):
for k,v in self.session.config:
self.SetParamsAttribute("BeremizRoot."+k, v)
@with_project_loaded
def build_project(self, target):
if target:
self.SetParamsAttribute("BeremizRoot.TargetType", target)
return 0 if self._Build() else 1
@with_project_loaded
@connected
def transfer_project(self):
return 0 if self._Transfer() else 1
@with_project_loaded
@connected
def run_project(self):
return 0 if self._Run() else 1
def finish(self):
self._Disconnect()
if not self.session.keep:
self.KillLocalRuntime()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。