diff --git a/pyUI/SkillComposer.py b/pyUI/SkillComposer.py index 2755ba3..aeeb801 100755 --- a/pyUI/SkillComposer.py +++ b/pyUI/SkillComposer.py @@ -1471,7 +1471,7 @@ def export(self): print('};') if file: - print(file.name) +# print(file.name) x = datetime.datetime.now() fileData = '# ' + file.name.split('/')[-1].split('.')[0] + '\n' fileData += 'Note: '+'You may add a short description/instruction here.\n\n' @@ -1492,18 +1492,23 @@ def export(self): fileData += '\n' fileData += '};' - # the file in the config directory wiill be saved automatically - filePathName = configDir + seperation + file.name.split('/')[-1] + # the file in the config directory will be saved automatically + filePathName = configDir + separation + 'SkillLibrary' + separation + self.model + separation + file.name.split('/')[-1] logger.debug(f"fileName is: {filePathName}") filePathList = [file.name, filePathName] for filePath in filePathList: + if filePath == filePathName: + modelDir = configDir + separation + 'SkillLibrary' + separation + self.model + makeDirectory(modelDir) try: with open(filePath, 'w+', encoding="utf-8") as f: f.write(fileData) time.sleep(0.1) + logger.info(f"save successfully: {filePath}") except Exception as e: - return False, 'save failed:{}'.format(e) + logger.info(f"save failed:{e}") + return False if self.gaitOrBehavior.get() == txt('Behavior'): skillData.insert(0, [loopStructure[0], loopStructure[-1], int(self.loopRepeat.get())]) diff --git a/pyUI/commonVar.py b/pyUI/commonVar.py index d07a661..75fb309 100644 --- a/pyUI/commonVar.py +++ b/pyUI/commonVar.py @@ -1,9 +1,16 @@ from translate import * +import platform import sys -sys.path.append('../serialMaster/') -resourcePath = './resources/' -releasePath = './release/' +if platform.system() == "Windows": # for Windows + sys.path.append('..\\serialMaster\\') + resourcePath = '.\\resources\\' + releasePath = '.\\release\\' +else: + sys.path.append('../serialMaster/') + resourcePath = './resources/' + releasePath = './release/' sys.path.append(resourcePath) + from ardSerial import * from tkinter import * from tkinter import messagebox @@ -12,7 +19,6 @@ import threading import random import datetime -import platform import os NyBoard_version = 'NyBoard_V1_2' @@ -53,7 +59,7 @@ ports = [] -def mkdir(path): +def makeDirectory(path): # delete spaces in the path string path = path.strip() # delete the '\' at the end of path string @@ -74,17 +80,17 @@ def mkdir(path): return False if platform.system() == "Windows": # for Windows - seperation = '\\' + separation = '\\' homeDri = os.getenv('HOMEDRIVE') homePath = os.getenv('HomePath') configDir = homeDri + homePath else: # for Linux & macOS - seperation = '/' + separation = '/' home = os.getenv('HOME') configDir = home -configDir = configDir + seperation +'.config' + seperation +'Petoi' -mkdir(configDir) -defaultConfPath = configDir + seperation + 'defaultConfig.txt' +configDir = configDir + separation +'.config' + separation +'Petoi' +makeDirectory(configDir) +defaultConfPath = configDir + separation + 'defaultConfig.txt' print(defaultConfPath) def createImage(frame, imgFile, imgW): diff --git a/pyUI/translate.py b/pyUI/translate.py index 83ae118..d3f43da 100644 --- a/pyUI/translate.py +++ b/pyUI/translate.py @@ -1,5 +1,5 @@ versionNum = '1.1.3' -dateStr = '2023-09-28' +dateStr = '2023-10-26' textEN = { 'lan':'English', diff --git a/serialMaster/ardSerial.py b/serialMaster/ardSerial.py index 99c904d..2f16706 100644 --- a/serialMaster/ardSerial.py +++ b/serialMaster/ardSerial.py @@ -32,7 +32,7 @@ def txt(key): The default starting point is INFO, which means that the logging module will automatically filter out any DEBUG messages. ''' -# logging.basicConfig(level=logging.DEBUG, format=FORMAT) +#logging.basicConfig(level=logging.DEBUG, format=FORMAT) logging.basicConfig(level=logging.INFO, format=FORMAT) logger = logging.getLogger(__name__) @@ -41,7 +41,7 @@ def printH(head, value): print(head, end=' ') print(value) -printH("ardSerial date: ", "Sep 26, 2023") +printH("ardSerial date: ", "Oct 10, 2023") def encode(in_str, encoding='utf-8'): if isinstance(in_str, bytes):