diff --git a/iRobot-Roomba.indigoPlugin/Contents/Info.plist b/iRobot-Roomba.indigoPlugin/Contents/Info.plist index 3bf04cf..e1acae8 100755 --- a/iRobot-Roomba.indigoPlugin/Contents/Info.plist +++ b/iRobot-Roomba.indigoPlugin/Contents/Info.plist @@ -3,7 +3,7 @@ PluginVersion - 0.9.18 + 0.9.19 ServerApiVersion 3.0 IwsApiVersion diff --git a/iRobot-Roomba.indigoPlugin/Contents/Server Plugin/plugin.py b/iRobot-Roomba.indigoPlugin/Contents/Server Plugin/plugin.py index 31fa6e6..21adb3c 100755 --- a/iRobot-Roomba.indigoPlugin/Contents/Server Plugin/plugin.py +++ b/iRobot-Roomba.indigoPlugin/Contents/Server Plugin/plugin.py @@ -26,6 +26,7 @@ import datetime from builtins import str as text import locale +import shutil #from requests.auth import HTTPBasicAuth #from requests.utils import quote @@ -67,7 +68,7 @@ def __init__(self, pluginId, pluginDisplayName, pluginVersion, pluginPrefs): self.logger.info(u"{0:=^130}".format("")) self.allMappingData = {} - + self.pluginprefDirectory = '{}/Preferences/Plugins/com.GlennNZ.indigoplugin.irobot/'.format(indigo.server.getInstallFolderPath()) try: self.logLevel = int(self.pluginPrefs[u"logLevel"]) except: @@ -118,6 +119,19 @@ def startup(self): self.logger.debug(u"updateFrequency = " + str(self.updateFrequency)) self.next_update_check = time.time() + if not os.path.exists(self.pluginprefDirectory): + os.makedirs(self.pluginprefDirectory) + + ## Check old config files and move them all. + try: + file_names = os.listdir(self.mainfolderLocation) + source_dir = self.mainfolderLocation + target_dir = self.pluginprefDirectory + for file_name in file_names: + shutil.move(os.path.join(source_dir, file_name), target_dir) + except: + self.logger.debug("Error trying to move files. Skippping.", exc_info=True) + self.continuous = self.pluginPrefs.get('continuous', False) #automatically disconnect reconnect even in continuous after elapsed time - 12 hours @@ -390,8 +404,10 @@ def deviceStartComm(self, device): #self.getRoombaInfo(device) #self.getRoombaStatus(device) #self.getRoombaTime(device) - MAChome = os.path.expanduser("~")+"/" - folderLocation = MAChome+"Documents/Indigo-iRobotRoomba/" + #MAChome = os.path.expanduser("~")+"/" + + folderLocation = self.pluginprefDirectory # MAChome+"Documents/Indigo-iRobotRoomba/" + roombaIP = str(device.states['IP']) filename = str(roombaIP)+"-mapping-data.json" file = folderLocation + filename @@ -585,8 +601,8 @@ def validateDeviceConfigUi(self, valuesDict, typeId, deviceId): ######################################## def checkConfigFile(self,valuesDict, deviceId): - MAChome = os.path.expanduser("~")+"/" - folderLocation = MAChome+"Documents/Indigo-iRobotRoomba/" + #MAChome = os.path.expanduser("~")+"/" + folderLocation = self.pluginprefDirectory #+"Documents/Indigo-iRobotRoomba/" roombaIP = valuesDict['address'] filename = str(roombaIP) + "-config.ini" file = folderLocation + filename @@ -770,8 +786,8 @@ def connectRoomba(self,device): self.logger.error(u"getDeviceStatus: Roomba IP address not configured.") return filename = text(roombaIP)+"-config.ini" - MAChome = os.path.expanduser("~")+"/" - folderLocation = MAChome+"Documents/Indigo-iRobotRoomba/" + # = os.path.expanduser("~")+"/" + folderLocation = self.pluginprefDirectory #+"Documents/Indigo-iRobotRoomba/" file = folderLocation + filename if self.debugOther: self.logger.debug(u'Using config file: ' + text(file)) diff --git a/iRobot-Roomba.indigoPlugin/Contents/Server Plugin/roomba.py b/iRobot-Roomba.indigoPlugin/Contents/Server Plugin/roomba.py index 6588100..d6d3d03 100755 --- a/iRobot-Roomba.indigoPlugin/Contents/Server Plugin/roomba.py +++ b/iRobot-Roomba.indigoPlugin/Contents/Server Plugin/roomba.py @@ -88,8 +88,9 @@ def __init__(self, plugin, address, useCloud, cloudLogin, cloudPassword, blid): self.plugin = plugin self.logger = logging.getLogger('Plugin.irobotAPI') - self.MAChome = os.path.expanduser("~")+"/" - self.folderLocation = self.MAChome+"Documents/Indigo-iRobotRoomba/" + #self.MAChome = os.path.expanduser("~")+"/" + self.folderLocation = self.plugin.pluginprefDirectory #self.MAChome+"Documents/Indigo-iRobotRoomba/" + self.file = self.folderLocation + str(address)+"-mapping-data.json" self.address = address self.useCloud = useCloud @@ -138,8 +139,8 @@ def __init__(self, plugin, address, useCloud, cloudLogin, cloudPassword,file="co self.iRoombaName = "" self.iRoombaMAC = "" self.iRoombaSWver ="" - self.MAChome = os.path.expanduser("~")+"/" - self.folderLocation = self.MAChome+"Documents/Indigo-iRobotRoomba/" + #self.MAChome = os.path.expanduser("~")+"/" + self.folderLocation = self.plugin.pluginprefDirectory #.self.MAChome+"Documents/Indigo-iRobotRoomba/" #self.logger = logging.getLogger('Roomba-Lib.iRobot') #self.folderLocation = self.plugin.folderLocation #self.log = logging.getLogger(__name__ + '.Roomba') @@ -607,9 +608,9 @@ def __init__(self, plugin, address=None, blid=None, password=None, topic="#", co #self.logger.error('software Version:'+self.softwareversion) #self.MACuserName = pwd.getpwuid(os.getuid())[0] - self.MAChome = os.path.expanduser("~")+"/" + # self.MAChome = os.path.expanduser("~")+"/" - self.folderLocation = self.MAChome+"Documents/Indigo-iRobotRoomba/" + self.folderLocation = self.plugin.pluginprefDirectory #.MAChome+"Documents/Indigo-iRobotRoomba/" self.file = self.folderLocation + file self.topic = topic