Skip to content

Commit

Permalink
0.9.19
Browse files Browse the repository at this point in the history
Move config files to Indigo Preferences directory (should have always been here)
Moves exisiting Documents config files and mapping data across

0.9.18
Fix for password file saving if using cloud and a few conditions set.
  • Loading branch information
Ghawken committed Aug 14, 2022
1 parent e496f24 commit 0701b98
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
2 changes: 1 addition & 1 deletion iRobot-Roomba.indigoPlugin/Contents/Info.plist
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>PluginVersion</key>
<string>0.9.18</string>
<string>0.9.19</string>
<key>ServerApiVersion</key>
<string>3.0</string>
<key>IwsApiVersion</key>
Expand Down
30 changes: 23 additions & 7 deletions iRobot-Roomba.indigoPlugin/Contents/Server Plugin/plugin.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
13 changes: 7 additions & 6 deletions iRobot-Roomba.indigoPlugin/Contents/Server Plugin/roomba.py
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0701b98

Please sign in to comment.