summaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2014-08-25 15:38:30 -0300
committerDuda Dornelles <ddornell@thoughtworks.com>2014-08-25 16:17:45 -0300
commit1475748fdcd8f11787392fa9c3eaece6b7338f6f (patch)
treee40f1480f22454323318307826275e227dc4bb3b /service
parent64e936cb72817970a09418cb0fe44d2572720785 (diff)
paths must be absolute for app to work as an egg. Also, packaging the
web-ui files
Diffstat (limited to 'service')
-rw-r--r--service/pixelated/adapter/mail_service.py2
-rw-r--r--service/pixelated/user_agent.py3
-rw-r--r--service/setup.py33
3 files changed, 35 insertions, 3 deletions
diff --git a/service/pixelated/adapter/mail_service.py b/service/pixelated/adapter/mail_service.py
index 822ea930..54deb488 100644
--- a/service/pixelated/adapter/mail_service.py
+++ b/service/pixelated/adapter/mail_service.py
@@ -33,7 +33,7 @@ class MailService:
self.password = password
self.server_name = server_name
self.mailbox_name = 'INBOX'
- self.certs_home = os.path.join(os.path.abspath("."), "pixelated", "certificates")
+ self.certs_home = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", "certificates"))
self.tags = Tags()
self._open_leap_session()
except:
diff --git a/service/pixelated/user_agent.py b/service/pixelated/user_agent.py
index f780cad6..270ca265 100644
--- a/service/pixelated/user_agent.py
+++ b/service/pixelated/user_agent.py
@@ -28,7 +28,8 @@ from pixelated.adapter.mail_service import MailService
from pixelated.adapter.pixelated_mail import PixelatedMail
from pixelated.tags import Tags
-app = Flask(__name__, static_url_path='', static_folder='../../web-ui/app')
+static_folder = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", "web-ui", "app"))
+app = Flask(__name__, static_url_path='', static_folder=static_folder)
app.config.from_pyfile(os.path.join(os.environ['HOME'], '.pixelated'))
mail_service = MailService(app.config['LEAP_USERNAME'], app.config['LEAP_PASSWORD'], app.config['LEAP_SERVER_NAME'])
diff --git a/service/setup.py b/service/setup.py
index b5f72fe5..2c7180be 100644
--- a/service/setup.py
+++ b/service/setup.py
@@ -20,8 +20,38 @@ if 'develop' in sys.argv:
sys.argv.append('--always-unzip')
from setuptools import setup
+from collections import defaultdict
import os
+
+def _folder_for(file):
+ broken_path = file.split('/')
+ new_path = "web-ui/app/" + "/".join(broken_path[3:(len(broken_path) -1)])
+ return new_path[0:-1] if new_path[-1] == '/' else new_path
+
+def _create_data_files(original_files):
+ data_files_hash = defaultdict(list)
+
+ for file in original_files:
+ data_files_hash[_folder_for(file)].append(file)
+
+ return data_files_hash.items()
+
+def _web_ui_files():
+ web_ui_files = []
+ for root, dirname, filenames in os.walk('../web-ui/dist'):
+ for filename in filenames:
+ web_ui_files.append(os.path.join(root, filename))
+ return web_ui_files
+
+def data_files():
+ certificates = ('pixelated/certificates', ['pixelated/certificates/example.wazokazi.is.ca.crt'])
+
+ _data_files = _create_data_files(_web_ui_files())
+ _data_files.append(certificates)
+
+ return _data_files
+
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
@@ -55,5 +85,6 @@ setup(name='Pixelated User Agent Service',
'console_scripts': [
'pixelated-user-agent = pixelated.user_agent:setup'
]
- }
+ },
+ data_files=data_files()
)