Пример #1
0
class CompilerUploader:
	def __init__(self):
		# self.pathToMain = os.path.dirname(os.path.realpath("web2board.py"))
		self.pathToMain = sys.path[0]
		self.arduino = ArduinoCompilerUploader(self.pathToMain)
		self.readConfigFile()

	def readConfigFile(self):
		with open(self.pathToMain+'/res/config.json') as json_data_file:
			data = json.load(json_data_file)
			self.version = str(data['version'])

	def getVersion (self):
		return self.version
	def setBoard (self, board):
		return self.arduino.setBoard(board)
	def setPort (self,port=''):
		self.arduino.setPort(port)
	def getPort (self):
		return self.arduino.getPort()
	def getBoard(self):
		return self.arduino.getBoard()
	def searchPort (self):
		return self.arduino.searchPort()
	def compile (self, code):
		return self.arduino.compile(code)
	def upload (self, code):
		return self.arduino.upload(code)
Пример #2
0
class CompilerUploader:
	def __init__(self):
		# self.pathToMain = os.path.dirname(os.path.realpath("web2board.py"))
		
		if platform.system() == 'Darwin':
			# logging.debug('sys.path[0]');
			# logging.debug(sys.path[0]);
			# logging.debug('PWD=');
			# logging.debug(os.environ.get('PWD'));
			# logging.debug('PYTHONPATH=');
			# logging.debug(os.environ.get('PYTHONPATH'));
			# logging.debug('ENVIRON=');
			# logging.debug(os.environ);
			if os.environ.get('PYTHONPATH') != None:
				self.pathToMain = os.environ.get('PYTHONPATH')
			else:
				self.pathToMain = sys.path[0]
		elif platform.system() == 'Windows' or platform.system() == 'Linux':
			self.pathToMain = sys.path[0]
		self.arduino = ArduinoCompilerUploader(self.pathToMain)
		self.readConfigFile()

	def readConfigFile(self):
		if not os.path.isfile(base.sys_path.get_home_path()+'/.web2boardconfig'):
			shutil.copyfile(self.pathToMain+'/res/config.json', base.sys_path.get_home_path()+'/.web2boardconfig')
		with open(base.sys_path.get_home_path()+'/.web2boardconfig') as json_data_file:
			data = json.load(json_data_file)
			self.version = str(data['version'])

	def getVersion (self):
		return self.version
	def setBoard (self, board):
		return self.arduino.setBoard(board)
	def setPort (self,port=''):
		self.arduino.setPort(port)
	def getPort (self):
		return self.arduino.getPort()
	def getBoard(self):
		return self.arduino.getBoard()
	def searchPort (self):
		return self.arduino.searchPort()
	def compile (self, code):
		return self.arduino.compile(code)
	def upload (self, code):
		return self.arduino.upload(code)
Пример #3
0
class CompilerUploader:
    def __init__(self):
        # self.pathToMain = os.path.dirname(os.path.realpath("web2board.py"))
        # initializing attributes
        self.arduino = ArduinoCompilerUploader(MAIN_PATH)
        self.version = None

        # executing initialization
        self.readConfigFile()

    def readConfigFile(self):
        if not os.path.isfile(WEB2BOARD_CONFIG_PATH):
            shutil.copyfile(RES_CONFIG_PATH, WEB2BOARD_CONFIG_PATH)
        with open(WEB2BOARD_CONFIG_PATH) as json_data_file:
            data = json.load(json_data_file)
            self.version = str(data['version'])

    def getVersion(self):
        return self.version

    def setBoard(self, board):
        return self.arduino.setBoard(board)

    def setPort(self, port=''):
        self.arduino.setPort(port)

    def getPort(self):
        return self.arduino.getPort()

    def getBoard(self):
        return self.arduino.getBoard()

    def searchPort(self):
        return self.arduino.searchPort()

    def compile(self, code):
        return self.arduino.compile(code)

    def upload(self, code):
        return self.arduino.upload(code)