本文整理汇总了Python中libs.Tools.isIOTFile方法的典型用法代码示例。如果您正苦于以下问题:Python Tools.isIOTFile方法的具体用法?Python Tools.isIOTFile怎么用?Python Tools.isIOTFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类libs.Tools
的用法示例。
在下文中一共展示了Tools.isIOTFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from libs import Tools [as 别名]
# 或者: from libs.Tools import isIOTFile [as 别名]
def __init__(self, view=False, console=False, install=False, command=True):
'''
Initialize the command and preferences classes, to check
if the current work file is an IoT type it received the view
parameter (ST parameter). This parameter is necessary only in
the options like build or upload.
Keyword Arguments:
view {st object} -- stores many info related with ST (default: False)
'''
self.Preferences = Preferences()
self.Menu = Menu()
# user console
if(console):
current_time = time.strftime('%H:%M:%S')
self.message_queue = MessageQueue(console)
self.message_queue.startPrint()
# For installing purposes
if(install):
self.Commands = CommandsPy(console=console)
return
self.view = view
self.execute = True
self.is_native = False
self.is_iot = False
if(view):
# avoid to do anything with a monitor view
view_name = view.name()
sketch_size = view.size()
file_path = Tools.getPathFromView(view)
if(not file_path and 'monitor' in view_name.lower()):
try:
current_time = time.strftime('%H:%M:%S')
self.message_queue.put('invalid_file_{0}', current_time)
except:
pass
self.execute = False
return
# unsaved file
if(command and not file_path and sketch_size > 0):
saved_file = self.saveCodeInFile(view)
view = saved_file[1]
file_path = Tools.getPathFromView(view)
if(command and not sketch_size):
self.message_queue.put('not_empty_sketch_{0}', current_time)
# current file / view
current_path = Paths.getCurrentFilePath(view)
if(not current_path):
return
self.is_iot = Tools.isIOTFile(view)
current_dir = Paths.getCWD(current_path)
parent_dir = Paths.getParentCWD(current_path)
file_name = Tools.getFileNameFromPath(file_path)
temp_name = Tools.getFileNameFromPath(current_path, ext=False)
if(not self.is_iot):
self.execute = False
# check IoT type file
if(console and not self.is_iot and not self.execute):
current_time = time.strftime('%H:%M:%S')
msg = 'not_iot_{0}{1}'
if(not file_name):
msg = 'not_empty_sketch_{0}'
self.message_queue.put(msg, current_time, file_name)
self.execute = False
return
if(not command and not self.is_iot):
return
# Check native project
for file in os.listdir(parent_dir):
if(file.endswith('platformio.ini')):
self.dir = parent_dir
self.src = False
self.is_native = True
break
# set native paths
if(not self.is_native):
build_dir = self.Preferences.get('build_dir', False)
if(not build_dir):
build_dir = Paths.getTempPath(temp_name)
self.src = current_dir
self.dir = build_dir
# unsaved changes
if (command and view.is_dirty()):
view.run_command('save')
if(console):
#.........这里部分代码省略.........