Example #1
0
File: run.py Project: 343max/Stino
	def run(self, menu_str):
		example = menu_str
		example_path = arduino_info.getExampleFolder(example)
		
		if arduino.isSketchFolder(example_path):
			example_name = os.path.split(example_path)[1]
			sketchbook_root = arduino_info.getSketchbookRoot()
			new_path = os.path.join(sketchbook_root, example_name)
			if os.path.exists(new_path):
				org_msg = '%(Sketch_Exists)s'
				msg = org_msg % cur_lang.getDisplayTextDict()
				sublime.message_dialog(msg)
				version = arduino_info.getVersion()
				if version >= 100:
					example_file = example_name + '.ino'
				else:
					example_file = example_name + '.pde'
				file_path = os.path.join(example_path, example_file)
				view = self.window.open_file(file_path)
			else:
				shutil.copytree(example_path, new_path, True)
				cur_menu.sketchbookUpdate()
				utils.openSketch(new_path)
		else:
			file_list = utils.listDir(example_path)
			self.level = 0
			self.top_path_list = [os.path.join(example_path, cur_file) for cur_file in file_list]
			self.path_list = self.top_path_list
			self.window.show_quick_panel(file_list, self.on_done)
Example #2
0
File: run.py Project: 343max/Stino
	def run(self):
		active_file = self.window.active_view().file_name()
		folder_path = os.path.split(active_file)[0]
		file_list = utils.listDir(folder_path)

		self.level = 0
		self.top_path_list = [os.path.join(folder_path, cur_file) for cur_file in file_list]
		self.path_list = self.top_path_list
		self.window.show_quick_panel(file_list, self.on_done)
Example #3
0
def getExampleList(path):
	example_list = []
	example_file_dict = {}
	example_root = os.path.join(path, 'examples')
	if os.path.isdir(example_root):
		dirs = utils.listDir(example_root, with_files = False)
		for cur_dir in dirs:
			cur_dir_path = os.path.join(example_root, cur_dir)
			example_list.append(cur_dir)
			example_file_dict[cur_dir] = cur_dir_path
	return (example_list, example_file_dict)
Example #4
0
def getLibList(path):
	lib_list = []
	lib_file_dict = {}
	lib_root = os.path.join(path, 'libraries')
	if os.path.isdir(lib_root):
		dirs = utils.listDir(lib_root, with_files = False)
		for cur_dir in dirs:
			cur_dir_path = os.path.join(lib_root, cur_dir)
			lib_list.append(cur_dir)
			lib_file_dict[cur_dir] = cur_dir_path
	return (lib_list, lib_file_dict)
Example #5
0
def getSketchList(path):
	sketch_list = []
	sketch_file_dict = {}
	if os.path.isdir(path):
		dirs = utils.listDir(path, with_files = False)
		for cur_dir in dirs:
			cur_dir_path = os.path.join(path, cur_dir)
			if isSketchFolder(cur_dir_path):
				sketch_list.append(cur_dir)
				sketch_file_dict[cur_dir] = cur_dir_path
	return (sketch_list, sketch_file_dict)
Example #6
0
	def genCoreFolderList(self):
		core_folder_list = []
		hardware_path_list = [os.path.join(self.arduino_root, 'hardware')]
		hardware_path_list.append(os.path.join(self.sketchbook_root, 'hardware'))
		for hardware_path in hardware_path_list:
			if os.path.isdir(hardware_path):
				dirs = utils.listDir(hardware_path, with_files = False)
				for cur_dir in dirs:
					if 'tools' in cur_dir:
						continue
					cur_dir_path = os.path.join(hardware_path, cur_dir)
					if isCoreFolder(cur_dir_path):
						core_folder_list.append(cur_dir_path)
					else:
						subdirs = utils.listDir(cur_dir_path, with_files = False)
						for cur_subdir in subdirs:
							cur_subdir_path = os.path.join(cur_dir_path, cur_subdir)
							if isCoreFolder(cur_subdir_path):
								core_folder_list.append(cur_subdir_path)
		self.core_folder_list = core_folder_list
Example #7
0
def getPlatform(path):
	platform = 'Arduino AVR Boards'
	info_file = os.path.join(path, 'platform.txt')
	if os.path.isfile(info_file):
		lines = utils.readFile(info_file, mode = 'lines')
		for line in lines:
			(key, value) = utils.getKeyValue(line)
			if key == 'name':
				platform = value
				break
	elif os.path.split(path)[1] != 'arduino':
		dirs = utils.listDir(path, with_files = False)
		if 'cores' in dirs:
			platform = os.path.split(path)[1]
			platform += ' %(Board)s'
	return platform