Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small change for config_dir #4

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion HouseAgent.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ logsize=1024
logcount=5
logconsole=True
dbpath=

runasservice=False

# -----------------------------------------------------------------------------
Expand Down
19 changes: 19 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
houseagent (0.01.20111116-2215-0ubuntu1) lucid; urgency=low

* Minor fixes and upstream changes.

-- David Whyte <[email protected]> Wed, 16 Nov 2011 22:16:15 +1000

houseagent (0.01.20111107-1217-0ubuntu1) lucid; urgency=low

* Changed the revision numbering to better support development packages.
* Created an upstart job for monitoring and management of HouseAgent.

-- David Whyte <[email protected]> Mon, 07 Nov 2011 12:18:14 +1000

houseagent (0.01.3-0ubuntu1) lucid; urgency=low

* Update to GIT revision 0efb44d. Remove dependency on RabbitMQ, add dependency on ZeroMQ.

-- David Whyte <[email protected]> Sun, 06 Nov 2011 23:11:11 +1000

houseagent (0.01-0ubuntu2) lucid; urgency=low

* Minor modifications of the packaging meta-data
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ Homepage: http://projects.maartendamen.com/projects/houseagent

Package: houseagent
Architecture: all
Depends: ${misc:Depends}, ${python:Depends}, rabbitmq-server, python-twisted-web, python-mako, python-pyrrd, python-txamqp, twisted.scheduling
Depends: ${misc:Depends}, ${python:Depends}, python-pyzmq, python-twisted-web, python-mako, python-pyrrd, python-txamqp, twisted.scheduling, txzmq
Description: Home automation core framework.
HouseAgent is a multi platform, open source home automation application.
11 changes: 11 additions & 0 deletions deploy/houseagent.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
description "HouseAgent management daemon"
author "David Whyte"

start on started network
stop on stopping network
stop on starting shutdown

console output

exec python /usr/bin/HouseAgent.py
respawn
24 changes: 13 additions & 11 deletions houseagent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ def config_file():
# Windows
if os.name == 'nt':

from win32com.shell import shellcon, shell
config_file = config_file = os.path.join(shell.SHGetFolderPath(0, shellcon.CSIDL_COMMON_APPDATA, 0, 0), 'HouseAgent', 'HouseAgent.conf')
from win32com.shell import shellcon, shell
config_dir = os.path.join(shell.SHGetFolderPath(0, shellcon.CSIDL_COMMON_APPDATA, 0, 0), 'HouseAgent')
config_file = os.path.join(config_dir, 'HouseAgent.conf')

if hasattr(sys, 'frozen'):
# Special case for binary Windows version
Expand All @@ -27,31 +28,32 @@ def config_file():
return config_file
elif os.path.exists(os.path.join(os.getcwd(), 'HouseAgent.conf')):
# development
return os.path.join(os.getcwd(), 'HouseAgent.conf')
return os.getcwd(), os.path.join(os.getcwd(), 'HouseAgent.conf')
else:
raise ConfigFileNotFound("ProgramData or working directory.")

# OSX and Linux
else:
config_file = os.path.join(os.sep, 'etc', 'HouseAgent.conf')
config_dir = os.path.join(os.sep, 'etc', 'HouseAgent')
config_file = os.path.join(config_dir, 'HouseAgent.conf')

if os.path.exists(config_file):
return config_file
return config_dir, config_file
elif os.path.exists(os.path.join(os.getcwd(), 'HouseAgent.conf')):
return os.path.join(os.getcwd(), 'HouseAgent.conf')
return os.getcwd(), os.path.join(os.getcwd(), 'HouseAgent.conf')
else:
raise ConfigFileNotFound("/etc/ or working directory.")
raise ConfigFileNotFound("/etc/HouseAgent/ or working directory.")

config_file = config_file()
config_dir, config_file = config_file()

""" Template directory """
if hasattr(sys, 'frozen'):
template_dir = os.path.join(os.path.dirname(sys.executable), 'templates')
else:
template_dir = os.path.join(os.path.dirname(__file__), 'templates')

""" Template plugin directory """
""" Plugin directory """
if hasattr(sys, 'frozen'):
template_plugin_dir = os.path.join(os.path.dirname(sys.executable), 'plugins')
plugin_dir = os.path.join(os.path.dirname(sys.executable), 'plugins')
else:
template_plugin_dir = os.path.join(os.path.dirname(__file__), 'plugins')
plugin_dir = os.path.join(os.path.dirname(__file__), 'plugins')
2 changes: 1 addition & 1 deletion houseagent/core/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,4 +1105,4 @@ def render_POST(self, request):
id = request.args["id"][0]

self.db.del_event(int(id)).addCallback(self.event_deleted)
return NOT_DONE_YET
return NOT_DONE_YET
8 changes: 4 additions & 4 deletions houseagent/templates/master.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
main_items.append(main_item)

parse_config(os.path.join(houseagent.template_dir, "menu.xml"))
for filename in os.listdir(houseagent.template_plugin_dir):
for filename in os.listdir(houseagent.plugin_dir):
if not os.path.isfile(filename):
if (os.path.exists(os.path.join(houseagent.template_plugin_dir, filename, "menu.xml"))):
parse_config(os.path.join(houseagent.template_plugin_dir, filename, "menu.xml"))
if (os.path.exists(os.path.join(houseagent.plugin_dir, filename, "menu.xml"))):
parse_config(os.path.join(houseagent.plugin_dir, filename, "menu.xml"))
%>
<html>
<head>
Expand Down Expand Up @@ -125,4 +125,4 @@
</div>
</div>
</body>
</html>
</html>
22 changes: 20 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
#!/usr/bin/env python

from distutils.core import setup
import ConfigParser
import os

version = '0.01'

def update_file(filename, search_line, replace_line):
infile = file(filename)
oldlines = infile.readlines()
infile.close

newlines = []
for line in oldlines:
if search_line in line:
line = replace_line
newlines.append(line)

outfile = file(filename, 'w')
outfile.writelines(newlines)


def find_package_files(workingdir, subdir):
currentDir = os.getcwd()
# Go into the working directory
Expand Down Expand Up @@ -37,9 +53,11 @@ def find_package_files(workingdir, subdir):
packages = ['houseagent','houseagent.core', 'houseagent.plugins', 'houseagent.utils', 'houseagent.pages'],
package_data = {'houseagent': template_files},
scripts = ['HouseAgent.py'],
data_files = [('/etc/HouseAgent', ['HouseAgent.conf', 'specs/amqp0-8.xml']),
('share/HouseAgent', ['houseagent.db'])],
data_files = [('/etc/HouseAgent', ['HouseAgent.conf', 'specs/amqp0-8.xml', 'houseagent.db']), ('/etc/init', ['deploy/houseagent.conf'])],
)

# For linux, specify the log and db paths
update_file('HouseAgent.conf', 'logpath=', 'logpath=/var/log/HouseAgent/')
update_file('HouseAgent.conf', 'dbpath=', 'dbpath=/etc/HouseAgent/houseagent.db')

setup(**data)