Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #64 from Borkason/remove-market

Remove market from the admin, it isn't online anymore. Thanks Borkason for these patches.
  • Loading branch information...
commit 0bdffcef82e126e940923b6a993ac3a33718ec61 2 parents 169bc5b + e4932c1
@skinkie skinkie authored
Showing with 42 additions and 4,548 deletions.
  1. +1 −5 admin/Makefile.am
  2. +0 −340 admin/OWS_Backup.py
  3. +0 −136 admin/OWS_Cherokee_Info.py
  4. +0 −136 admin/OWS_Login.py
  5. +0 −110 admin/OWS_Market_Info.py
  6. +0 −1  admin/Page.py
  7. +0 −14 admin/PageAdvanced.py
  8. +1 −4 admin/PageEntry.py
  9. +0 −53 admin/PageError.py
  10. +1 −154 admin/PageIndex.py
  11. +1 −5 admin/PageVServer.py
  12. +1 −24 admin/PageVServers.py
  13. +0 −4 admin/configured.py.pre
  14. +0 −266 admin/market/CommandProgress.py
  15. +0 −167 admin/market/Distro.py
  16. +0 −531 admin/market/Install.py
  17. +0 −96 admin/market/InstallUtil.py
  18. +0 −72 admin/market/Install_Log.py
  19. +0 −106 admin/market/Library.py
  20. +0 −595 admin/market/Maintenance.py
  21. +0 −27 admin/market/Makefile.am
  22. +0 −55 admin/market/Menu.py
  23. +0 −218 admin/market/PageApp.py
  24. +0 −96 admin/market/PageCategory.py
  25. +0 −155 admin/market/PageIndex.py
  26. +0 −97 admin/market/PageSearch.py
  27. +0 −144 admin/market/Report.py
  28. +0 −98 admin/market/Review.py
  29. +0 −245 admin/market/Util.py
  30. +0 −37 admin/market/__init__.py
  31. +0 −44 admin/market/ows_consts.py
  32. +0 −45 admin/server.py
  33. +0 −461 admin/static/css/cherokee-admin.css
  34. +0 −2  admin/static/images/Makefile.am
  35. BIN  admin/static/images/market.png
  36. BIN  admin/static/images/sidebar-market.png
  37. +0 −1  admin/theme.html
  38. +37 −3 admin/wizards/php.py
  39. +0 −1  configure.ac
View
6 admin/Makefile.am
@@ -1,6 +1,6 @@
## Cherokee: Makefile.am -*- makefile -*-
-SUBDIRS = market plugins wizards CTK icons
+SUBDIRS = plugins wizards CTK icons
if INSTALL_ADMIN
SUBDIRS += static
@@ -44,10 +44,6 @@ Graph.py \
Handler.py \
Icons.py \
Mime.py \
-OWS_Backup.py \
-OWS_Cherokee_Info.py \
-OWS_Login.py \
-OWS_Market_Info.py \
Page.py \
PageAdvanced.py \
PageEntry.py \
View
340 admin/OWS_Backup.py
@@ -1,340 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Cherokee-admin
-#
-# Authors:
-# Alvaro Lopez Ortega
-# Taher Shihadeh
-#
-# Copyright (C) 2001-2013 Alvaro Lopez Ortega
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of version 2 of the GNU General Public
-# License as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-
-import copy
-import time
-import socket
-
-import CTK
-import OWS_Login
-import XMLServerDigest
-
-from configured import *
-
-OWS_BACKUP = 'http://www.octality.com/api/v%s/backup/' %(OWS_API_VERSION)
-
-URL_BASE = '/backup'
-URL_SAVE_NOTE = '%s/save/note' %(URL_BASE)
-URL_SAVE_FAIL = '%s/save/fail' %(URL_BASE)
-URL_SAVE_SUCCESS = '%s/save/success' %(URL_BASE)
-URL_SAVE_APPLY = '%s/save/apply' %(URL_BASE)
-URL_RESTORE_NOTE = '%s/restore/note' %(URL_BASE)
-URL_RESTORE_FAIL = '%s/restore/fail' %(URL_BASE)
-URL_RESTORE_SUCCESS = '%s/restore/success' %(URL_BASE)
-URL_RESTORE_APPLY = '%s/restore/apply' %(URL_BASE)
-
-NOTE_SAVE_H2 = N_('Remote Configuration Back Up')
-NOTE_SAVE_P1 = N_('Your current configuration is about to be backed up.')
-NOTE_SAVE_P2 = N_('By submitting the form it will be stored at a remote location and will be made available to you for future use.')
-NOTE_SAVE_FAIL_H2 = N_('Could not Upload the Configuration File')
-NOTE_SAVE_FAIL_P1 = N_('An error occurred while uploading your configuration file. Please try again later.')
-NOTE_SAVE_OK_H2 = N_('Configuration File Successfully uploaded')
-NOTE_SAVE_OK_P1 = N_('Your configuration file has been saved. From now on the back-up will be available for restoration.')
-
-NOTE_RESTORE_H2 = N_('Remote Configuration Restoration')
-NOTE_RESTORE_P1 = N_('Select a configuration state to restore. Submitting the form will download and restore a previous configuration.')
-NOTE_RESTORE_P2 = N_('You might want to save the current one before you proceed.')
-NOTE_RESTORE_NO = N_('No configurations could be retireved. It seems you have not uploaded any configuration yet.')
-
-NOTE_RESTORE_ERROR_H2 = N_('Could not retrieve the configuration file list')
-NOTE_RESTORE_ERROR_P1 = N_('An error occurred while trying to fetch the configuration file list from the remote server.')
-NOTE_RESTORE_FAIL_H2 = N_('Could not restore the selected configuration file')
-NOTE_RESTORE_FAIL_P1 = N_('An error occurred while trying to restore a remotely-stored configuration file.')
-NOTE_RESTORE_OK_H2 = N_('The Configuration File was restored successfully')
-NOTE_RESTORE_OK_P1 = N_('The configuration has been rolled back to a previous version.')
-NOTE_RESTORE_OK_P2_1 = N_('Please, click the Save button if you want to commit the changes.')
-NOTE_RESTORE_OK_P2_2 = N_('Your current Configuration file matches the restored version.')
-
-
-#
-# Apply
-#
-
-class Apply:
- class Save:
- def __call__ (self):
- comment = CTK.post.get_val('comment')
- config = CTK.cfg.serialize()
-
- del (CTK.cfg['tmp!backup!save'])
-
- try:
- xmlrpc = XMLServerDigest.XmlRpcServer (OWS_BACKUP, OWS_Login.login_user, OWS_Login.login_password)
- ret = xmlrpc.upload (CTK.util.to_unicode(config),
- CTK.util.to_unicode(comment))
- except socket.error, (value, message):
- CTK.cfg['tmp!backup!save!type'] = 'socket'
- CTK.cfg['tmp!backup!save!error'] = message
- return {'ret': 'error', 'error': message}
- except Exception, e:
- CTK.cfg['tmp!backup!save!type'] = 'general'
- CTK.cfg['tmp!backup!save!error'] = str(e)
- return {'ret': 'error', 'error': str(e)}
-
- return {'ret': ret}
-
- class Restore:
- def __call__ (self):
- version = CTK.post.get_val('version')
-
- del (CTK.cfg['tmp!backup!restore'])
-
- try:
- xmlrpc = XMLServerDigest.XmlRpcServer (OWS_BACKUP, OWS_Login.login_user, OWS_Login.login_password)
- cfg_str = xmlrpc.download (version)
- cfg = CTK.Config()
-
- cfg._parse (cfg_str)
- CTK.cfg.root = copy.deepcopy(cfg.root)
- except socket.error, (value, message):
- CTK.cfg['tmp!backup!restore!type'] = 'socket'
- CTK.cfg['tmp!backup!restore!error'] = message
- return {'ret': 'error', 'error': message}
- except Exception, e:
- CTK.cfg['tmp!backup!restore!type'] = 'general'
- CTK.cfg['tmp!backup!restore!error'] = str(e)
- return {'ret': 'error', 'error': str(e)}
-
- return CTK.cfg_reply_ajax_ok()
-
-
-class Save_Config_Button (CTK.Box):
- def __init__ (self):
- CTK.Box.__init__ (self, {'class': 'backup-save'})
-
- # Druid
- druid = CTK.Druid (CTK.RefreshableURL())
- dialog = CTK.Dialog ({'title': _(NOTE_SAVE_H2), 'width': 480})
- dialog += druid
- druid.bind ('druid_exiting', dialog.JS_to_close())
-
- # Trigger button
- link = CTK.Link ("#", CTK.RawHTML(_('Back up…')))
- link.bind ('click', druid.JS_to_goto('"%s"'%(URL_SAVE_NOTE)) + dialog.JS_to_show())
-
- self += dialog
- self += link
-
-
-#
-# Save Druid
-#
-
-class Backup_Save_Note:
- def __call__ (self):
- # Form
- submit = CTK.Submitter (URL_SAVE_APPLY)
- submit += CTK.TextArea ({'name': 'comment', 'class': 'noauto backup-notes-textarea optional', 'style': 'width: 436px; height: 48px; margin-top: 8px;' })
- submit.bind ('submit_success', CTK.DruidContent__JS_to_goto (submit.id, URL_SAVE_SUCCESS))
- submit.bind ('submit_fail', CTK.DruidContent__JS_to_goto (submit.id, URL_SAVE_FAIL))
-
- # Buttons
- panel = CTK.DruidButtonsPanel()
- panel += CTK.DruidButton_Close (_('Cancel'))
- panel += CTK.DruidButton_Submit (_('Back Up'))
-
- # Layout
- content = CTK.Container()
- content += CTK.RawHTML ('<p>%s</p>'%(_(NOTE_SAVE_P1)))
- content += CTK.RawHTML ('<p>%s</p>'%(_(NOTE_SAVE_P2)))
- box = CTK.Box()
- box += CTK.RawHTML ("<strong>%s</strong>" %(_("Notes")))
- box += submit
- content += box
- content += panel
-
- return content.Render().toStr()
-
-class Backup_Save_Fail:
- def __call__ (self):
- panel = CTK.DruidButtonsPanel()
- panel += CTK.DruidButton_Close (_('Close'))
-
- # Layout
- content = CTK.Container()
- content += CTK.RawHTML('<h2>%s</h2>' %(_(NOTE_SAVE_FAIL_H2)))
- content += CTK.RawHTML('<p>%s</p>' %(_(NOTE_SAVE_FAIL_P1)))
- content += CTK.RawHTML('<p><pre>%s</pre></p>' %(CTK.escape_html (CTK.cfg.get_val('tmp!backup!save!error',''))))
- content += panel
- return content.Render().toStr()
-
-class Backup_Save_Success:
- def __call__ (self):
- panel = CTK.DruidButtonsPanel()
- panel += CTK.DruidButton_Close (_('Close'))
-
- # Layout
- content = CTK.Container()
- content += CTK.RawHTML('<h2>%s</h2>' %(_(NOTE_SAVE_OK_H2)))
- content += CTK.RawHTML('<p>%s</p>' %(_(NOTE_SAVE_OK_P1)))
- content += panel
- return content.Render().toStr()
-
-
-#
-# Restore Druid
-#
-
-class Restore_Config_Form (CTK.Submitter):
- def __init__ (self, configs):
- CTK.Submitter.__init__ (self, URL_RESTORE_APPLY)
-
- # Build table
- table = CTK.Table ({'class': 'backup-restore-table'})
- table += [CTK.RawHTML(x) for x in ('', _('Back Up Date'), _('Annotations'))]
- table.set_header(1)
-
- # Populate it
- for cfg in configs:
- version, date, annotation = cfg
-
- # Parse time
- iso8601_date = str(date)
- time_tuple = time.strptime (iso8601_date.replace("-", ""), "%Y%m%dT%H:%M:%S")
-
- # Add the row
- widget = CTK.Radio ({'name':'version', 'value':version, 'group':'config_version', 'class': 'noauto'})
- table += [widget, CTK.RawHTML('<em>%s</em>'%(time.asctime(time_tuple))), CTK.RawHTML(annotation)]
-
- self += table
-
-
-class Backup_Restore_Note:
- def __call__ (self):
- configs = _get_configs()
- panel = CTK.DruidButtonsPanel()
- content = CTK.Container()
-
- error = CTK.cfg.get_val('tmp!backup!retrieve!error', '')
- if error:
- content += CTK.RawHTML('<h2>%s</h2>' %(_(NOTE_RESTORE_ERROR_H2)))
- content += CTK.RawHTML('<p>%s</p>' %(_(NOTE_RESTORE_ERROR_P1)))
- content += CTK.RawHTML('<p><pre>%s</pre></p>' %(CTK.escape_html(error)))
- content += panel
- panel += CTK.DruidButton_Close (_('Close'))
-
- elif not configs:
- # Content
- content += CTK.Notice (content = CTK.RawHTML (_(NOTE_RESTORE_NO)))
- content += panel
-
- # Buttons
- panel += CTK.DruidButton_Close (_('Close'))
-
- else:
- form = Restore_Config_Form (configs)
- form.bind ('submit_success', CTK.DruidContent__JS_to_goto (form.id, URL_RESTORE_SUCCESS))
- form.bind ('submit_fail', CTK.DruidContent__JS_to_goto (form.id, URL_RESTORE_FAIL))
-
- # Content
- content += CTK.RawHTML ('<p>%s</p>'%(_(NOTE_RESTORE_P1)))
- content += CTK.RawHTML ('<p>%s</p>'%(_(NOTE_RESTORE_P2)))
- content += form
- content += panel
-
- # Buttons
- panel += CTK.DruidButton_Close (_('Cancel'))
- panel += CTK.DruidButton_Submit (_('Restore'))
-
- return content.Render().toStr()
-
-class Backup_Restore_Fail:
- def __call__ (self):
- panel = CTK.DruidButtonsPanel()
- panel += CTK.DruidButton_Close (_('Close'))
-
- content = CTK.Container()
- content += CTK.RawHTML('<h2>%s</h2>' %(_(NOTE_RESTORE_FAIL_H2)))
- content += CTK.RawHTML('<p>%s</p>' %(_(NOTE_RESTORE_FAIL_P1)))
- content += CTK.RawHTML('<p><pre>%s</pre></p>' %(CTK.escape_html (CTK.cfg.get_val('tmp!backup!restore!error',''))))
- content += panel
- return content.Render().toStr()
-
-class Backup_Restore_Success:
- def __call__ (self):
- panel = CTK.DruidButtonsPanel()
- panel += CTK.DruidButton_Close (_('Close'))
-
- content = CTK.Container()
- content += CTK.RawHTML('<h2>%s</h2>' %(_(NOTE_RESTORE_OK_H2)))
- content += CTK.RawHTML('<p>%s</p>' %(_(NOTE_RESTORE_OK_P1)))
-
- if CTK.cfg.has_changed():
- content += CTK.RawHTML('<p>%s</p>' %(_(NOTE_RESTORE_OK_P2_1)))
- else:
- content += CTK.RawHTML('<p>%s</p>' %(_(NOTE_RESTORE_OK_P2_2)))
-
- content += panel
- return content.Render().toStr()
-
-class Restore_Config_Button (CTK.Box):
- def __init__ (self):
- CTK.Box.__init__ (self, {'class': 'backup-restore'})
-
- # Druid
- druid = CTK.Druid (CTK.RefreshableURL())
- dialog = CTK.Dialog ({'title': _(NOTE_RESTORE_H2), 'width': 480})
- dialog += druid
-
- # Trigger button
- link = CTK.Link ("#", CTK.RawHTML(_('Restore…')))
- link.bind ('click', druid.JS_to_goto('"%s"'%(URL_RESTORE_NOTE)) + dialog.JS_to_show())
-
- self += dialog
- self += link
-
-
-#
-# Utils
-#
-
-def _get_configs():
- del (CTK.cfg['tmp!backup!retrieve'])
-
- try:
- xmlrpc = XMLServerDigest.XmlRpcServer (OWS_BACKUP, OWS_Login.login_user, OWS_Login.login_password)
- configs = xmlrpc.list_extended ()
- configs.reverse()
- except socket.error, (value, message):
- CTK.cfg['tmp!backup!retrieve!type'] = 'socket'
- CTK.cfg['tmp!backup!retrieve!error'] = message
- return None
- except Exception, e:
- CTK.cfg['tmp!backup!retrieve!type'] = 'general'
- CTK.cfg['tmp!backup!retrieve!error'] = str(e)
- return None
-
- return configs
-
-
-CTK.publish (r'^%s$'%(URL_SAVE_NOTE), Backup_Save_Note)
-CTK.publish (r'^%s$'%(URL_SAVE_FAIL), Backup_Save_Fail)
-CTK.publish (r'^%s$'%(URL_SAVE_SUCCESS), Backup_Save_Success)
-CTK.publish (r'^%s' %(URL_SAVE_APPLY), Apply.Save, method="POST")
-
-CTK.publish (r'^%s$'%(URL_RESTORE_NOTE), Backup_Restore_Note)
-CTK.publish (r'^%s$'%(URL_RESTORE_FAIL), Backup_Restore_Fail)
-CTK.publish (r'^%s$'%(URL_RESTORE_SUCCESS), Backup_Restore_Success)
-CTK.publish (r'^%s' %(URL_RESTORE_APPLY), Apply.Restore, method="POST")
View
136 admin/OWS_Cherokee_Info.py
@@ -1,136 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Cherokee-admin
-#
-# Authors:
-# Alvaro Lopez Ortega
-#
-# Copyright (C) 2001-2013 Alvaro Lopez Ortega
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of version 2 of the GNU General Public
-# License as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-
-
-import CTK
-import time
-
-from util import version_cmp
-from XMLServerDigest import XmlRpcServer
-from configured import *
-
-OWS_RPC = 'http://www.octality.com/api/v%s/open/cherokee-info/' %(OWS_API_VERSION)
-EXPIRATION = 10*60 # 10 min
-
-BETA_TESTER_NOTICE = N_("Thank you for testing a development snapshot (%(VERSION)s). It helps us to create the highest quality product.")
-
-
-class Latest_Release (CTK.Box):
- cache_info = None
- cache_expiration = 0
-
- def __init__ (self):
- CTK.Box.__init__ (self)
-
- if Latest_Release.cache_info and \
- Latest_Release.cache_expiration > time.time():
- self += CTK.RawHTML (self.cache_info)
- else:
- self += CTK.XMLRPCProxy ('cherokee-latest-release',
- xmlrpc_func = XmlRpcServer(OWS_RPC).get_latest,
- format_func = self.format,
- debug = True)
-
- def format (self, response):
- response = CTK.util.to_utf8(response)
- latest = response['default']
-
- # Render
- content = CTK.Box ({'id': 'latest-release-box', 'class': 'sidebar-box'})
- content += CTK.RawHTML('<h2>%s</h2>' % _('Latest Release'))
-
- if not latest:
- content += CTK.RawHTML(_('Latest version could not be determined at the moment.'))
- else:
- # Compare the release string
- d = version_cmp (latest['version'], VERSION)
- if d == 0:
- content += CTK.RawHTML (_('Cherokee is up to date') + ': %s'%(VERSION))
- elif d == 1:
- content += CTK.RawHTML ('%s v%s. %s v%s.' %(_('You are running Cherokee'),
- VERSION, _('Latest release is '),
- latest['version']))
- else:
- content += CTK.RawHTML (_(BETA_TESTER_NOTICE)%(globals()))
-
- # Update cache
- Latest_Release.cache_info = content.Render().toStr()
- Latest_Release.cache_expiration = time.time() + EXPIRATION
-
- return Latest_Release.cache_info
-
-
-#
-# Deprecated?
-#
-
-class Remote_Tweets (CTK.XMLRPCProxy):
- def __init__ (self):
- CTK.XMLRPCProxy.__init__ (self, 'cherokee-tweets',
- XmlRpcServer(OWS_RPC).get_tweets,
- self.format, debug=True)
-
- def format (self, response):
- response = CTK.util.to_utf8(response)
-
- # [{'date':'', 'link':'Link to the tweet', 'tweet':'', 'txt':'tweet without links'},...]
- lst = CTK.List()
- for r in response:
- lst.Add (CTK.RawHTML('%s <span class="tweet-date">%s</span>'% (r['tweet'], r['date'])))
-
- return lst.Render().toStr()
-
-
-class Remote_Mailing_List (CTK.XMLRPCProxy):
- def __init__ (self):
- CTK.XMLRPCProxy.__init__ (self, 'cherokee-mailing-list',
- XmlRpcServer(OWS_RPC).get_mailing_list,
- self.format, debug=True)
-
- def format (self, response):
- response = CTK.util.to_utf8(response)
-
- # [{'authors': '', 'date': '', 'hits': d, 'link', '', 'subject': ''},...]
- lst = CTK.List()
- for r in response:
- lst.Add (CTK.RawHTML('<a href="%s">%s</a> (%s)'% (r['link'],r['subject'], r['authors'])))
-
- return lst.Render().toStr()
-
-class Remote_Commits (CTK.XMLRPCProxy):
- def __init__ (self):
- CTK.XMLRPCProxy.__init__ (self, 'cherokee-commits',
- XmlRpcServer(OWS_RPC).get_commits,
- self.format, debug=True)
-
- def format (self, response):
- response = CTK.util.to_utf8(response)
-
- # [{'date': '', 'log': '', 'revision': 'dddd', 'time': 'hh:mm:ss', 'url': '', 'user': 'taher'},...]
- lst = CTK.List()
- for r in response:
- lst.Add ([CTK.Box({'class': 'revision'}, CTK.RawHTML('<a href="%s">%s</a>' %(r['url'], r['revision']))),
- CTK.Box({'class': 'log'}, CTK.RawHTML(r['log']))])
-
- return lst.Render().toStr()
View
136 admin/OWS_Login.py
@@ -1,136 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Cherokee-admin
-#
-# Authors:
-# Alvaro Lopez Ortega
-#
-# Copyright (C) 2001-2013 Alvaro Lopez Ortega
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of version 2 of the GNU General Public
-# License as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-
-import CTK
-import XMLServerDigest
-
-from configured import *
-
-
-LOGIN_APPLY = '/login/apply'
-SIGNOUT_APPLY = '/signout/apply'
-
-OWS_WEB_REGISTER = 'http://cherokee-market.com/signup'
-OWS_WEB_LOGIN = 'https://www.octality.com/api/v%s/login' %(OWS_API_VERSION)
-OWS_WEB_USER = 'http://cherokee-market.com/user/%s'
-
-NOTE_REGISTER = N_('<span class="register-link">Not registered yet? <a target = "_blank" href="%s">Join today</a>.</span>')
-
-login_user = None
-login_password = None
-login_session = None
-
-def log_in (user, password):
- global login_user, login_password, login_session
-
- if is_logged():
- return True
-
- # NOTE: This request uses the provided login/password pair to
- # access the web service. It requires Digest authentication. It
- # will fail if the pair is not valid.
- #
- try:
- xmlrpc = XMLServerDigest.XmlRpcServer (OWS_WEB_LOGIN, user, password)
- session = xmlrpc.is_logged()
- if session:
- login_user = user
- login_password = password
- login_session = session
- CTK.cfg["admin!ows!login!user"] = user
- CTK.cfg["admin!ows!login!password"] = password
- return True
- except:
- CTK.util.print_exception()
- return None
-
- return False
-
-
-def is_logged():
- global login_user, login_password
-
- if login_user and login_password:
- return True
-
- return False
-
-
-def Login_Apply():
- # Validation
- if not CTK.post['email']:
- return {'ret':'error', 'errors': {'email': _("Can not be empty")}}
- if not CTK.post['password']:
- return {'ret':'error', 'errors': {'password': _("Can not be empty")}}
-
- # Authenticate
- prev_changes = CTK.cfg.has_changed()
-
- logged = log_in (CTK.post['email'], CTK.post['password'])
- if logged == True:
- # Auto-save it there were no prev changes
- if not prev_changes:
- CTK.cfg.save()
-
- return {'ret':'ok'}
-
- return {'ret':'error', 'errors': {'password': _("Authentication failed")}}
-
-def SignOut_Apply():
- global login_user, login_password
- login_user = None
- login_password = None
- return CTK.HTTP_Redir("/")
-
-
-class LoginDialog (CTK.Dialog):
- def __init__ (self):
- CTK.Dialog.__init__ (self, {'title': _("Sign in to Cherokee Market")}, {'id': 'login-dialog'})
-
- submit = CTK.Submitter (LOGIN_APPLY)
- submit += CTK.RawHTML (_('Email address'))
- submit += CTK.TextField ({'name': 'email', 'class': 'noauto'})
- submit += CTK.RawHTML (_('Password'))
- submit += CTK.TextFieldPassword ({'name': 'password', 'class': 'noauto'})
- submit += CTK.SubmitterButton (_("Sign in"))
-
- bottompanel = CTK.Box ({'id': 'login-bottom'})
- bottompanel += CTK.RawHTML (_(NOTE_REGISTER) %(OWS_WEB_REGISTER))
-
- self += submit
- self += bottompanel
-
-class LoggedAs_Text (CTK.Box):
- def __init__ (self):
- CTK.Box.__init__ (self, {'class': 'login-box-logged-in'})
-
- self += CTK.RawHTML('%s ' %(_("Logged as")))
- self += CTK.LinkWindow (OWS_WEB_USER %(login_user), CTK.RawHTML(login_user))
- self += CTK.RawHTML(" (")
- self += CTK.Link (SIGNOUT_APPLY, CTK.RawHTML(_("Sign out")))
- self += CTK.RawHTML(")")
-
-
-CTK.publish (r'^%s' %(LOGIN_APPLY), Login_Apply, method="POST")
-CTK.publish (r'^%s$'%(SIGNOUT_APPLY), SignOut_Apply)
View
110 admin/OWS_Market_Info.py
@@ -1,110 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Cherokee-admin
-#
-# Authors:
-# Alvaro Lopez Ortega
-#
-# Copyright (C) 2001-2013 Alvaro Lopez Ortega
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of version 2 of the GNU General Public
-# License as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-
-import CTK
-
-from configured import *
-from util import version_cmp
-from XMLServerDigest import XmlRpcServer
-from configured import *
-
-DEBUG = True
-OWS_RPC = 'http://www.octality.com/api/v%s/open/market/info/' %(OWS_API_VERSION)
-
-
-def invalidate_caches():
- Index_Block1.cached = None
- Index_Block2.cached = None
-
-
-#
-# Index
-#
-class Index_Block1 (CTK.Container):
- cached = None
-
- def format_func (self, raw_cont):
- cont = CTK.util.to_utf8 (raw_cont)
- Index_Block1.cached = cont
- return cont
-
- def __init__ (self):
- CTK.Container.__init__ (self)
-
- # Skip the XML-RPC if OWS is inactive
- if not int (CTK.cfg.get_val ("admin!ows!enabled", OWS_ENABLE)):
- return
-
- # Instance the XML-RPC Proxy object
- if Index_Block1.cached:
- self += CTK.RawHTML (Index_Block1.cached)
- else:
- self += CTK.XMLRPCProxy (name = 'cherokee-index-block1',
- xmlrpc_func = lambda: XmlRpcServer(OWS_RPC).get_block_index_1 (CTK.i18n.active_lang, VERSION),
- format_func = self.format_func,
- props = {'class': 'main-banner'},
- debug = DEBUG)
-
-
-class Index_Block2 (CTK.Container):
- cached = None
-
- def format_func (self, raw_cont):
- cont = CTK.util.to_utf8 (raw_cont)
- Index_Block2.cached = cont
- return cont
-
- def __init__ (self):
- CTK.Container.__init__ (self)
-
- # Skip the XML-RPC if OWS is inactive
- if not int (CTK.cfg.get_val ('admin!ows!enabled', OWS_ENABLE)):
- return
-
- # Instance the XML-RPC Proxy object
- if Index_Block2.cached:
- self += CTK.RawHTML (Index_Block2.cached)
- else:
- self += CTK.XMLRPCProxy (name = 'cherokee-index-block2',
- xmlrpc_func = lambda: XmlRpcServer(OWS_RPC).get_block_index_2 (CTK.i18n.active_lang, VERSION),
- format_func = self.format_func,
- debug = DEBUG)
-
-
-#
-# Market
-#
-class Market_Block1 (CTK.XMLRPCProxy):
- def __init__ (self):
- CTK.XMLRPCProxy.__init__ (self, name = 'cherokee-market-block1',
- xmlrpc_func = lambda: XmlRpcServer(OWS_RPC).get_block_market_1 (CTK.i18n.active_lang, VERSION),
- format_func = lambda x: x,
- debug = DEBUG)
-
-class Market_Block2 (CTK.XMLRPCProxy):
- def __init__ (self):
- CTK.XMLRPCProxy.__init__ (self, name = 'cherokee-market-block2',
- xmlrpc_func = lambda: XmlRpcServer(OWS_RPC).get_block_market_2 (CTK.i18n.active_lang, VERSION),
- format_func = lambda x: x,
- debug = DEBUG)
View
1  admin/Page.py
@@ -153,7 +153,6 @@ def __init__ (self, title, headers=[], body_id=None, **kwargs):
template['save'] = _('Save')
template['home'] = _('Home')
template['status'] = _('Status')
- template['market'] = _('Apps')
template['general'] = _('General')
template['vservers'] = _('vServers')
template['sources'] = _('Sources')
View
14 admin/PageAdvanced.py
@@ -59,7 +59,6 @@
("server!tls!dh_param1024", validations.is_local_file_exists),
("server!tls!dh_param2048", validations.is_local_file_exists),
("server!tls!dh_param4096", validations.is_local_file_exists),
- ("admin!ows!repository", validations.is_http_url),
]
WARNING = N_("""<p><b>WARNING</b>: This section contains advanced
@@ -93,7 +92,6 @@
NOTE_DH4096 = N_('Path to a Diffie Hellman (DH) parameters PEM file: 4096 bits.')
NOTE_TLS_TIMEOUT = N_('Timeout for the TLS/SSL handshake. Default: 15 seconds.')
NOTE_TLS_SSLv2 = N_('Allow clients to use SSL version 2 - Beware: it is vulnerable. (Default: No)')
-NOTE_APPS_REPO = N_('HTTP address of an anternative Cherokee applications repository.')
HELPS = [('config_advanced', N_('Advanced'))]
@@ -185,17 +183,6 @@ def __init__ (self):
self += CTK.RawHTML ("<h2>%s</h2>" %(_('TLS')))
self += CTK.Indenter(table)
-class AppsWidget (CTK.Container):
- def __init__ (self):
- CTK.Container.__init__ (self)
-
- table = CTK.PropsAuto(URL_APPLY)
- table.Add (_('Repository Address'), CTK.TextCfg('admin!ows!repository', True, {'optional_string':_("Main repository")}), _(NOTE_APPS_REPO))
-
- self += CTK.RawHTML ("<h2>%s</h2>" %(_('Apps Center')))
- self += CTK.Indenter(table)
-
-
class Render:
def __call__ (self):
tabs = CTK.Tab()
@@ -204,7 +191,6 @@ def __call__ (self):
tabs.Add (_('I/O cache'), IOCacheWidget())
tabs.Add (_('Special Files'), SpecialFilesWidget())
tabs.Add (_('TLS'), TLSWidget())
- tabs.Add (_('Apps'), AppsWidget())
notice = CTK.Notice('warning')
notice += CTK.RawHTML(_(WARNING))
View
5 admin/PageEntry.py
@@ -511,10 +511,7 @@ def __init__ (self, vsrv, rule, apply):
key = 'vserver!%s!rule!%s!document_root'%(vsrv, rule)
table2 = CTK.PropsTable()
- if not CTK.cfg.get_val (key, '').startswith(CHEROKEE_OWS_ROOT):
- table2.Add (_('Document Root'), CTK.TextCfg(key, True), _(Handler.NOTE_DOCUMENT_ROOT))
- else:
- table2.Add (_('Document Root'), CTK.TextCfg(key, True, {'disabled':True}), _(Handler.NOTE_DOCUMENT_ROOT))
+ table2.Add (_('Document Root'), CTK.TextCfg(key, True), _(Handler.NOTE_DOCUMENT_ROOT))
submit = CTK.Submitter (apply)
submit += table2
View
53 admin/PageError.py
@@ -179,56 +179,3 @@ def __init__ (self, path, **kwargs):
def AncientConfig (file):
return AncientConfigError(file).Render()
-
-
-
-OWS_DIR_P1 = N_("A problem with the installation directories has been found. The %s directory is missing and it could not be created by Cherokee-Admin.")
-OWS_DIR_P2 = N_("Please, create it and try again:")
-
-OWS_PERM_P1 = N_("A problem with the installation directories has been found. The %(dir)s directory has the wrong permissions. It must be writable by the UID %(uid)s.")
-OWS_PERM_P2 = N_("Please, fix it and try again:")
-
-class OWSDirectoryError (CTK.Page):
- def __init__ (self, **kwargs):
- srcdir = os.path.dirname (os.path.realpath (__file__))
- theme_file = os.path.join (srcdir, 'exception.html')
-
- # Set up the template
- template = CTK.Template (filename = theme_file)
- template['body_props'] = ' id="body-error"'
- template['title'] = _('An Incomplete Installation was detected')
-
- # Parent's constructor
- CTK.Page.__init__ (self, template, **kwargs)
-
- # Write the right message
- errors = False
-
- for d in (CHEROKEE_OWS_DIR, CHEROKEE_OWS_ROOT):
- if not os.path.isdir (d):
- self += CTK.RawHTML ('<h1>%s</h1>'%(_('Missing Directory')))
- self += CTK.RawHTML ('<p>%s</p>'%(_(OWS_DIR_P1)%(d)))
- self += CTK.RawHTML ('<p>%s</p>'%(_(OWS_DIR_P2)))
- self += CTK.RawHTML ("<p><pre>mkdir -p -m 0755 '%s'</pre>" %(d))
- self += CTK.RawHTML ("<pre>chown -R %d '%s'</pre></p>" %(os.getuid(), d))
- errors = True
- break
-
- if not os.access (d, os.W_OK):
- self += CTK.RawHTML ('<h1>%s</h1>'%(_('Installation Problem')))
- self += CTK.RawHTML ('<p>%s</p>'%(_(OWS_PERM_P1)%({'dir':d, 'uid':os.getuid()})))
- self += CTK.RawHTML ('<p>%s</p>'%(_(OWS_PERM_P2)))
- self += CTK.RawHTML ("<pre>chown -R %d '%s'</pre></p>" %(os.getuid(), d))
- self += CTK.RawHTML ("<pre>chmod -R 0775 '%s'</pre></p>" %(d))
- errors = True
- break
-
- if errors:
- button = CTK.Button (_("Try Again"))
- button.bind ('click', CTK.JS.ReloadURL())
- self += button
- else:
- self += CTK.RawHTML (js = CTK.JS.ReloadURL())
-
-def OWSDirectory():
- return OWSDirectoryError().Render()
View
155 admin/PageIndex.py
@@ -26,8 +26,6 @@
import CTK
import Page
import Cherokee
-import xmlrpclib
-import XMLServerDigest
import PageError
import SystemStats
import SystemStatsWidgets
@@ -39,20 +37,13 @@
import urllib2
import re
-import OWS_Login
-import OWS_Backup
-import OWS_Market_Info
-import OWS_Cherokee_Info
-
from util import *
from consts import *
from configured import *
# URLs
-LINK_OCTALITY = 'http://www.octality.com/'
LINK_SUPPORT = 'http://www.octality.com/engineering.html'
-OWS_PROUD = 'http://www.octality.com/api/v%s/open/proud/' %(OWS_API_VERSION)
-PROUD_USERS_WEB = "http://www.cherokee-project.com/cherokee-domain-list.html"
+
# Links
LINK_BUGTRACKER = 'http://bugs.cherokee-project.com/'
@@ -84,32 +75,12 @@
RUNNING_NOTICE = N_('Server is Running')
STOPPED_NOTICE = N_('Server is not Running')
-PROUD_USERS_NOTICE = N_("""\
-We would love to know that you are using Cherokee. Submit your domain
-name and it will be listed on the Cherokee Project web site.
-""")
-# Dialogs
-PROUD_DIALOG_OK = N_("The information has been successfully sent. Thank you!")
-PROUS_DIALOG_ERROR1 = N_("Unfortunatelly something went wrong, and the information could not be submitted:")
-PROUS_DIALOG_ERROR2 = N_("Please, try again. Do not hesitate to report the problem if it persists.")
-
-#
-REMOTE_SERVS_APPLY = '/remote-servs/apply'
-REMOTE_SERVS_ENABLE = N_('Enable Remote Services')
# Help entries
HELPS = [('config_status', N_("Status"))]
-# JS
-JS_SUBSCRIBE = """
-$('#subscribe-a').click (function(){ %s });
-"""
-JS_PROUD = """
-$('#proud-a').click (function(){ %s });
-"""
-
JS_SCROLL = """
function resize_cherokee_containers() {
$('#home-container').height($(window).height() - 106);
@@ -184,61 +155,6 @@ def _get_cfg_ctime (self):
info = os.stat(CTK.cfg.file)
return time.ctime(info.st_ctime)
-
-def RemoteServices_Apply():
- enabled = CTK.post.get_val('admin!ows!enabled')
- CTK.cfg['admin!ows!enabled'] = enabled
- return CTK.cfg_reply_ajax_ok()
-
-
-class RemoteServices (CTK.Box):
- def __init__ (self):
- CTK.Box.__init__ (self, {'id': 'remote-services-section', 'class': 'infosection'})
-
- submit = CTK.Submitter (REMOTE_SERVS_APPLY)
- submit += CTK.CheckCfgText ("admin!ows!enabled", True, _(REMOTE_SERVS_ENABLE))
- submit.bind ('submit_success', CTK.JS.GotoURL('/'))
-
- infotable = CTK.Table({'class': 'info-table'})
- infotable.set_header (column=True, num=1)
-
- if int (CTK.cfg.get_val("admin!ows!enabled", OWS_ENABLE)):
- if OWS_Login.is_logged():
- infotable += [submit, OWS_Login.LoggedAs_Text()]
- else:
- dialog = OWS_Login.LoginDialog()
- dialog.bind ('submit_success', CTK.JS.GotoURL('/'))
-
- link = CTK.Link ("#", CTK.RawHTML('<span>%s</span>' %(_('Sign in'))))
- link.bind ('click', dialog.JS_to_show())
-
- cont = CTK.Container()
- cont += dialog
- cont += link
-
- infotable += [submit, cont]
- else:
- infotable += [submit]
-
- table = CTK.Table()
- table.set_header (column=True, num=1)
- table += [CTK.RawHTML (_('Remote Services')), infotable]
- self += table
-
-class BackupService (CTK.Box):
- def __init__ (self):
- CTK.Box.__init__ (self, {'id': 'remote-backup-section', 'class': 'infosection'})
-
- cont = CTK.Container()
- cont += OWS_Backup.Restore_Config_Button()
- cont += OWS_Backup.Save_Config_Button()
-
- table = CTK.Table()
- table.set_header (column=True, num=1)
- table += [CTK.RawHTML (_('Backup Service')), cont]
- self += table
-
-
class CPUInfo (CTK.Box):
def __init__ (self):
CTK.Box.__init__ (self, {'id': 'cpu-section', 'class': 'infosection'})
@@ -268,7 +184,6 @@ def language_set (langs):
CTK.util.print_exception()
return True
-
def Lang_Apply():
# Sanity check
lang = CTK.post.get_val('lang')
@@ -278,7 +193,6 @@ def Lang_Apply():
language_set (lang)
CTK.cfg['admin!lang'] = lang
- OWS_Market_Info.invalidate_caches()
return {'ret': 'ok', 'redirect': '/'}
@@ -295,57 +209,6 @@ def __init__ (self):
self += CTK.RawHTML('%s: ' %(_('Language')))
self += submit
-
-def ProudUsers_Apply():
- # Collect domains
- domains = []
-
- for v in CTK.cfg.keys('vserver'):
- domains.append (CTK.cfg.get_val('vserver!%s!nick'%(v)))
-
- for d in CTK.cfg.keys('vserver!%s!match!domain'%(v)):
- domains.append (CTK.cfg.get_val('vserver!%s!match!domain!%s'%(v, d)))
-
- for d in CTK.cfg.keys('vserver!%s!match!regex'%(v)):
- domains.append (CTK.cfg.get_val('vserver!%s!match!regex!%s'%(v, d)))
-
- # Send the list
- try:
- xmlrpc = XMLServerDigest.XmlRpcServer (OWS_PROUD)
- xmlrpc.add_domains_to_review(domains)
-
- except xmlrpclib.ProtocolError, err:
- details = "Error code: %d\n" % err.errcode
- details += "Error message: %s\n" % err.errmsg
- details += "Headers: %s\n" % err.headers
-
- return '<p>%s</p>' %(_(PROUS_DIALOG_ERROR1)) + \
- '<p><pre>%s</pre></p>' %(CTK.escape_html(details)) + \
- '<p>%s</p>' %(_(PROUS_DIALOG_ERROR2))
-
- except Exception, e:
- return '<p>%s</p>' %(_(PROUS_DIALOG_ERROR1)) + \
- '<p><pre>%s\n</pre></p>' %(CTK.escape_html(str(e))) + \
- '<p>%s</p>' %(_(PROUS_DIALOG_ERROR2))
-
- return "<p>%s</p>" %(_(PROUD_DIALOG_OK))
-
-
-class ProudUsers (CTK.Box):
- def __init__ (self):
- CTK.Box.__init__ (self, {'id': 'proud-users', 'class': 'sidebar-box'})
-
- # Dialog
- dialog = CTK.DialogProxyLazy ('/proud/apply', {'title': _('Proud Cherokee User List Submission'), 'width': 480})
- dialog.AddButton (_('Close'), "close")
-
- self += CTK.RawHTML('<h2>%s</h2>' %(_('Proud Cherokee Users')))
- self += CTK.Box ({'id': 'proud-notice'}, CTK.RawHTML (_(PROUD_USERS_NOTICE)))
- self += CTK.Box ({'id': 'proud-link'}, CTK.RawHTML ('<a target="_blank" href="%s">%s</a> | <a id="proud-a">%s</a>' %(_(PROUD_USERS_WEB), _('View list…'), _('Send your domains'))))
- self += CTK.RawHTML (js=JS_PROUD %(dialog.JS_to_show()))
- self += dialog
-
-
def Subscribe_Apply ():
values = {}
for k in CTK.post:
@@ -464,15 +327,7 @@ def __call__ (self):
# Content: Left
mainarea = CTK.Box({'id': 'main-area'})
- mainarea += OWS_Market_Info.Index_Block1()
mainarea += ServerInfo()
- if int(OWS_ENABLE):
- mainarea += RemoteServices()
-
- if OWS_Login.is_logged() and \
- int (CTK.cfg.get_val("admin!ows!enabled", OWS_ENABLE)):
- mainarea += BackupService()
-
mainarea += CPUInfo()
mainarea += MemoryInfo()
mainarea += CommunityBar()
@@ -480,12 +335,6 @@ def __call__ (self):
# Content: Right
sidebar = CTK.Box({'id': 'sidebar'})
sidebar += SupportBox()
-
- if int (CTK.cfg.get_val("admin!ows!enabled", OWS_ENABLE)):
- sidebar += OWS_Cherokee_Info.Latest_Release()
-
- sidebar += ProudUsers()
- sidebar += OWS_Market_Info.Index_Block2()
sidebar += HaltAdmin()
# Content
@@ -507,6 +356,4 @@ def __call__ (self):
CTK.publish (r'^/stop$', Stop)
CTK.publish (r'^/halt$', Halt)
CTK.publish (r'^/lang/apply', Lang_Apply, method="POST")
-CTK.publish (r'^/proud/apply', ProudUsers_Apply, method="POST")
CTK.publish (r'^%s'%(SUBSCRIBE_APPLY), Subscribe_Apply, method="POST")
-CTK.publish (r'^%s'%(REMOTE_SERVS_APPLY), RemoteServices_Apply, method="POST")
View
6 admin/PageVServer.py
@@ -458,11 +458,7 @@ def __init__ (self, vsrv_num):
# Paths
table = CTK.PropsAuto (url_apply)
- if not CTK.cfg.get_val ('%s!document_root'%(pre),'').startswith(CHEROKEE_OWS_ROOT):
- table.Add (_('Document Root'), CTK.TextCfg('%s!document_root'%(pre)), _(NOTE_DOCUMENT_ROOT))
- else:
- table.Add (_('Document Root'), CTK.TextCfg('%s!document_root'%(pre), False, {'disabled':True}), _(NOTE_DOCUMENT_ROOT))
-
+ table.Add (_('Document Root'), CTK.TextCfg('%s!document_root'%(pre)), _(NOTE_DOCUMENT_ROOT))
table.Add (_('Directory Indexes'), CTK.TextCfg('%s!directory_index'%(pre)), _(NOTE_DIRECTORY_INDEX))
self += CTK.RawHTML ('<h2>%s</h2>' %(_('Paths')))
View
25 admin/PageVServers.py
@@ -201,12 +201,7 @@ def __init__ (self, refresh, right_box):
for k in vservers:
# Document root widget
droot_str = CTK.cfg.get_val ('vserver!%s!document_root'%(k), '')
-
- # Market install base scenario
- if self.__is_market_installation (k, droot_str):
- droot_widget = CTK.Box ({'class': 'droot'}, CTK.RawHTML(_('Market installation')))
- else:
- droot_widget = CTK.Box ({'class': 'droot'}, CTK.RawHTML(CTK.escape_html (droot_str)))
+ droot_widget = CTK.Box ({'class': 'droot'}, CTK.RawHTML(CTK.escape_html (droot_str)))
if k == vservers[-1]:
content = [entry('nick', 'vserver!%s!nick'%(k)), droot_widget]
@@ -247,24 +242,6 @@ def __init__ (self, refresh, right_box):
# List entry
panel.Add (k, '/vserver/content/%s'%(k), content, True, disclass)
-
- def __is_market_installation (self, k, droot_str):
- # Market install base scenario
- if droot_str.startswith (CHEROKEE_OWS_ROOT):
- return True
-
- # Market install with no droot
- elif droot_str == '/dev/null':
- rules = CTK.cfg['vserver!%s!rule'%(k)].keys()
- for rule_num in rules:
- src_num = CTK.cfg.get_val ('vserver!%s!rule!%s!handler!balancer!source!1' %(k,rule_num), '')
- src_int = CTK.cfg.get_val ('source!%s!interpreter'%(src_num), '')
- if CHEROKEE_OWS_ROOT in src_int:
- return True
-
- return False
-
-
class PanelButtons (CTK.Box):
def __init__ (self):
CTK.Box.__init__ (self, {'class': 'panel-buttons'})
View
4 admin/configured.py.pre
@@ -9,8 +9,6 @@ WWWROOT = "%wwwroot%"
SYSCONFDIR = "%sysconfdir%"
LOCALSTATE = "%localstatedir%"
VERSION = "%version%"
-OWS_ENABLE = '1'
-OWS_API_VERSION = '2'
CHEROKEE_SERVER = join (PREFIX, "sbin/cherokee")
CHEROKEE_WORKER = join (PREFIX, "sbin/cherokee-worker")
@@ -26,5 +24,3 @@ CHEROKEE_VAR_LOG = join (LOCALSTATE, "log")
CHEROKEE_VAR_RUN = join (LOCALSTATE, "run")
CHEROKEE_VAR_LIB = join (LOCALSTATE, "lib/cherokee")
CHEROKEE_RRD_DIR = join (LOCALSTATE, "lib/cherokee/graphs")
-CHEROKEE_OWS_DIR = join (LOCALSTATE, "lib/cherokee/ows")
-CHEROKEE_OWS_ROOT = join (LOCALSTATE, "lib/cherokee/ows/root")
View
266 admin/market/CommandProgress.py
@@ -1,266 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Cherokee-admin
-#
-# Authors:
-# Alvaro Lopez Ortega <alvaro@alobbs.com>
-#
-# Copyright (C) 2001-2013 Alvaro Lopez Ortega
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of version 2 of the GNU General Public
-# License as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-
-import os
-import CTK
-import popen
-import traceback
-import threading
-import SystemInfo
-import Install_Log
-import InstallUtil
-
-MORE = N_("Show error details")
-LESS = N_("Hide error details")
-DELAY = 500 #ms
-
-def error_to_HTML (error):
- # error = error.replace ('\n', '<br/>')
- error = error.replace ('\x07', '')
- error = error.replace ('\r', '')
- error = error.replace ('', '')
- return CTK.escape_html (error)
-
-
-class Replacement_Dict:
- def __init__ (self):
- self.keys = {}
-
- def __setitem__ (self, key, func):
- self.keys[key] = func
-
- def replace (self, txt):
- for k in self.keys:
- macro = '${%s}'%(k)
- if macro in txt:
- val = self.keys[k]
- if hasattr (val, '__call__'):
- replacement = val()
- else:
- replacement = val
- txt = txt.replace (macro, replacement)
- return txt
-
-
-class Replacement_Commons (Replacement_Dict):
- def __init__ (self):
- Replacement_Dict.__init__ (self)
-
- # Install user (root, whell, admin, etc)
- root_user = InstallUtil.get_installation_UID()
- root_group = InstallUtil.get_installation_GID()
-
- # Server user (www-data, server, nobody, etc)
- #
- # Unusual case: getgroups() might return []. We try to cover
- # the corner case by assuming a safety value of [0] (because
- # we haven't any other better option, actually).
- groups = os.getgroups() or [0]
- groups.sort()
-
- server_user = CTK.cfg.get_val ('server!user', str(os.getuid()))
- server_group = CTK.cfg.get_val ('server!group', str(groups[0]))
-
- # Directories
- app_root = CTK.cfg.get_val ('tmp!market!install!root')
-
- # Replacements
- self['web_user'] = server_user
- self['web_group'] = server_group
- self['root_user'] = root_user
- self['root_group'] = root_group
- self['app_root'] = app_root
-
-
-class CommandProgress (CTK.Box, Replacement_Commons):
- class Exec (CTK.Container):
- def __init__ (self, command_progress):
- CTK.Container.__init__ (self)
-
- # Length and current
- commands_len = len(command_progress.commands)
- if command_progress.error or \
- command_progress.executed >= commands_len:
- command_entry = command_progress.commands [command_progress.executed - 1]
- else:
- command_entry = command_progress.commands [command_progress.executed]
-
- # Title
- if command_entry.has_key('description'):
- title = CTK.escape_html (command_entry['description'])
- elif command_entry.has_key('command'):
- title = CTK.escape_html (command_entry['command'])
- elif command_entry.has_key('function'):
- title = CTK.escape_html (command_entry['function'].__name__)
- else:
- assert False, 'Unknown command entry type'
-
- # Error
- if command_progress.error:
- ret = command_progress.last_popen_ret
- percent = command_progress.executed * 100.0 / (commands_len + 1)
-
- if ret.get('command'):
- title_error = CTK.escape_html (ret['command'])
- elif command_entry.has_key ('function'):
- title_error = CTK.escape_html (command_entry['function'].__name__)
- else:
- title_error = _("Unknown Error")
-
- error_content = CTK.Box ({'class': 'market-commands-exec-error-details'})
- error_content += CTK.RawHTML ("<pre>%s</pre>" %(error_to_HTML(ret['stderr'])))
-
- details = CTK.CollapsibleEasy ((_(MORE), _(LESS)))
- details += error_content
-
- self += CTK.ProgressBar ({'value': percent})
- self += CTK.RawHTML ("<p><b>%s</b>: %s</p>" %(_("Error executing"), title_error))
- self += details
- return
-
- # Regular
- percent = (command_progress.executed + 1) * 100.0 / (commands_len + 1)
- self += CTK.ProgressBar ({'value': percent})
- self += CTK.Box ({'class': 'market-commands-exec-command'}, CTK.RawHTML ("<p>%s</p>" %(title)))
-
- # Next step
- if command_progress.executed < commands_len:
- JS = "update = function(){%s}; setTimeout ('update()', %s);"
- self += CTK.RawHTML (js = JS%(command_progress.refresh.JS_to_refresh(), DELAY))
- else:
- self += CTK.RawHTML (js = CTK.DruidContent__JS_to_goto (command_progress.id, command_progress.finished_url))
-
- def Render (self):
- # Add replacement keys to the log
- for k in self.keys:
- Install_Log.log (" ${%s} -> '%s'" %(k, self.keys[k]))
-
- # Start thread
- self.thread.start()
-
- # Render
- return CTK.Box.Render (self)
-
- def __init__ (self, commands, finished_url, props={}):
- CTK.Box.__init__ (self, props.copy())
- Replacement_Commons.__init__ (self)
-
- self.finished_url = finished_url
- self.commands = commands
- self.error = False
- self.executed = 0
- self.last_popen_ret = None
-
- self.refresh = CTK.Refreshable ({'id': 'market-commands-exec'})
- self.refresh.register (lambda: CommandProgress.Exec(self).Render())
- self += self.refresh
-
- self.thread = CommandExec_Thread (self)
-
-
-class CommandExec_Thread (threading.Thread):
- def __init__ (self, command_progress):
- threading.Thread.__init__ (self)
- self.daemon = True
- self.command_progress = command_progress
-
- def run (self):
- for command_entry in self.command_progress.commands:
- if command_entry.has_key ('command'):
- error = self._run_command (command_entry)
- elif command_entry.has_key ('function'):
- error = self._run_function (command_entry)
- else:
- assert False, 'Unknown command type'
-
- self.command_progress.executed += 1
- if error:
- self.command_progress.error = True
- break
-
- def _replace (self, txt):
- return self.command_progress.replace (txt)
-
- def _run_command (self, command_entry):
- command = self._replace (command_entry['command'])
- cd = command_entry.get('cd')
- env = command_entry.get('env')
- su = command_entry.get('su')
-
- if cd:
- cd = self._replace (cd)
-
- Install_Log.log (" %s" %(command))
- if env:
- Install_Log.log (" (CD) -> %s" %(cd))
- Install_Log.log (" (SU) -> %s" %(su))
- Install_Log.log (" (CUSTOM ENV) -> %s" %(str(env)))
-
- ret = popen.popen_sync (command, env=env, cd=cd, su=su)
- self.command_progress.last_popen_ret = ret
-
- if command_entry.get ('check_ret', True):
- if ret['retcode'] != 0:
- self._report_error (command, env, ret, cd)
- return True
-
- def _run_function (self, command_entry):
- function = command_entry['function']
- params = command_entry.get ('params', {}).copy()
-
- Install_Log.log (" Function: %s" %(function.__name__))
- if params:
- Install_Log.log (" (PARAMS) -> %s" %(str(params)))
-
- try:
- ret = function (**params)
- except:
- ret = {'retcode': 1,
- 'stderr': traceback.format_exc()}
-
- self.command_progress.last_popen_ret = ret
-
- if command_entry.get ('check_ret', True):
- if ret['retcode'] != 0:
- self._report_error (function.__name__, params, ret)
- return True
-
- def _report_error (self, command, env, ret_exec, cd=None):
- print "="*40
- if env:
- for k in env:
- print "%s='%s' \\"%(k, env[k].replace("'","\\'"))
- print "-"*40
- if cd:
- print cd
- else:
- print os.getcwd()
- print "-"*40
- print command
- print "-"*40
- print ret_exec.get('stdout','')
- print "-"*40
- print ret_exec.get('stderr','')
- print "="*40
-
View
167 admin/market/Distro.py
@@ -1,167 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Cherokee-admin
-#
-# Authors:
-# Alvaro Lopez Ortega <alvaro@alobbs.com>
-#
-# Copyright (C) 2001-2013 Alvaro Lopez Ortega
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of version 2 of the GNU General Public
-# License as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-
-import CTK
-
-import re
-import os
-import sys
-import gzip
-import time
-import urllib2
-import threading
-
-from util import *
-from consts import *
-from ows_consts import *
-from configured import *
-
-
-global_index = None
-global_index_lock = threading.Lock()
-
-def Index():
- global global_index
-
- global_index_lock.acquire()
-
- if not global_index:
- try:
- global_index = Index_Class()
- except:
- global_index_lock.release()
- raise
-
- global_index_lock.release()
- return global_index
-
-
-def cached_download (url, return_content=False):
- # Open the connection
- request = urllib2.Request (url)
- opener = urllib2.build_opener()
-
- # Cache file
- url_md5 = CTK.util.md5 (url).hexdigest()
- cache_file = os.path.join (CHEROKEE_OWS_DIR, url_md5)
-
- tmp = url.split('?',1)[0] # Remove params
- ext = tmp.split('.')[-1] # Extension
- if len(ext) in range(2,5):
- cache_file += '.%s'%(ext)
-
- # Check previos version
- if os.path.exists (cache_file):
- s = os.stat (cache_file)
- t = time.strftime ("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(s.st_mtime))
- request.add_header ('If-Modified-Since', t)
-
- # Send request
- try:
- if sys.version_info < (2, 6):
- stream = opener.open (request)
- else:
- stream = opener.open (request, timeout=10)
- except urllib2.HTTPError, e:
- if e.code == 304:
- # 304: Not Modified
- if return_content:
- return open (cache_file, 'rb').read()
- return cache_file
- raise
-
- # Content
- content = stream.read()
-
- # Store
- f = open (cache_file, "wb+")
- f.write (content)
- f.close()
-
- if return_content:
- return open (cache_file, 'rb').read()
- return cache_file
-
-
-class Index_Class:
- def __init__ (self):
- repo_url = CTK.cfg.get_val ('admin!ows!repository', REPO_MAIN)
-
- self.url = os.path.join (repo_url, 'index.py.gz')
- self.content = {}
- self.local_file = None
- self.error = False
-
- # Initialization
- self.Update()
-
- def Update (self):
- # Download
- try:
- local_file = cached_download (self.url)
- except urllib2.HTTPError, e:
- self.error = True
- return
-
- # Shortcut: Do not parse if it hasn't changed
- if ((local_file == self.local_file) and
- (os.stat(local_file).st_mtime == os.stat(self.local_file).st_mtime)):
- return
- self.local_file = local_file
-
- # Read
- f = gzip.open (local_file, 'rb')
- content = f.read()
- f.close()
-
- # Parse
- self.content = CTK.util.data_eval (content)
-
- def __getitem__ (self, k):
- return self.content[k]
-
- def get (self, k, default=None):
- return self.content.get (k, default)
-
- # Helpers
- #
- def get_package (self, pkg, prop=None):
- pkg = self.content.get('packages',{}).get(pkg)
- if pkg and prop:
- return pkg.get(prop)
- return pkg
-
- def get_package_list (self):
- return self.content.get('packages',{}).keys()
-
-
-if __name__ == "__main__":
- i = Index()
- i.Download()
- i.Parse()
-
- print i['build_date']
- print i.get_package_list()
- print i.get_package('phpbb')
- print i.get_package('phpbb', 'installation')
View
531 admin/market/Install.py
@@ -1,531 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Cherokee-admin
-#
-# Authors:
-# Alvaro Lopez Ortega <alvaro@alobbs.com>
-#
-# Copyright (C) 2001-2013 Alvaro Lopez Ortega
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of version 2 of the GNU General Public
-# License as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-
-import CTK
-
-import re
-import os
-import imp
-import stat
-import sys
-import time
-import tarfile
-import traceback
-import OWS_Login
-import Maintenance
-import Library
-import Install_Log
-import SystemInfo
-import SystemStats
-import SaveButton
-import Cherokee
-import Distro
-import popen
-import CommandProgress
-import InstallUtil
-
-from util import *
-from consts import *
-from ows_consts import *
-from configured import *
-
-from XMLServerDigest import XmlRpcServer
-
-PAYMENT_CHECK_TIMEOUT = 5 * 1000 # 5 secs
-
-NOTE_ALREADY_INSTALLED = N_('The application is already in your library, so there is no need the buy it again. Please, proceed to the installation.')
-
-NOTE_ALL_READY_TO_BUY_1 = N_('You are about to purchase the application. Please proceed with the Check Out to provide the payment details.')
-NOTE_ALL_READY_TO_BUY_2 = N_('The application will be downloaded and installed afterwards, and will remain in your library for future installations.')
-
-NOTE_THANKS_P1 = N_("Cherokee is now ready to run the application. Please, remember to backup your configuration if you are going to perform customizations.")
-NOTE_THANKS_P2 = N_("Thank you for buying at Cherokee's Market!")
-NOTE_SAVE_RESTART = N_("Since there were previous changes your configuration has not been applied automatically. Please do it yourself by clicking the SAVE button on the top-right corner.")
-
-NO_ROOT_H1 = N_("Privileges test failed")
-NO_ROOT_P1 = N_("Since the installations may require administrator to execute system administration commands, it is required to run Cherokee-admin under a user with administrator privileges.")
-NO_ROOT_P2 = N_("Please, run cherokee-admin as root to solve the problem.")
-
-MIN_VER_H1 = N_("The package cannot be installed")
-MIN_VER_p1 = N_("This package required at least Cherokee %(version)s to be installed.")
-
-
-URL_INSTALL_WELCOME = "%s/install/welcome" %(URL_MAIN)
-URL_INSTALL_INIT_CHECK = "%s/install/check" %(URL_MAIN)
-URL_INSTALL_PAY_CHECK = "%s/install/pay" %(URL_MAIN)
-URL_INSTALL_DOWNLOAD = "%s/install/download" %(URL_MAIN)
-URL_INSTALL_DOWNLOAD_ERROR = "%s/install/download_error" %(URL_MAIN)
-URL_INSTALL_SETUP = "%s/install/setup" %(URL_MAIN)
-URL_INSTALL_POST_UNPACK = "%s/install/post_unpack" %(URL_MAIN)
-URL_INSTALL_EXCEPTION = "%s/install/exception" %(URL_MAIN)
-URL_INSTALL_SETUP_EXTERNAL = "%s/install/setup/package" %(URL_MAIN)
-URL_INSTALL_DONE = "%s/install/done" %(URL_MAIN)
-URL_INSTALL_DONE_CONTENT = "%s/install/done/content" %(URL_MAIN)
-URL_INSTALL_DONE_APPLY = "%s/install/done/apply" %(URL_MAIN)
-
-
-class InstallDialog (CTK.Dialog):
- def __init__ (self, app_name):
- index = Distro.Index()
- app = index.get_package (app_name, 'software')
-
- title = "%s%s" %(app['name'], _("Cherokee Market"))
-
- CTK.Dialog.__init__ (self, {'title': title, 'width': 600, 'minHeight': 300})
- self.info = app
-
- # Copy a couple of preliminary config entries
- CTK.cfg['tmp!market!install!app!application_id'] = app['id']
- CTK.cfg['tmp!market!install!app!application_name'] = app['name']
-
- self.refresh = CTK.RefreshableURL()
- self.druid = CTK.Druid(self.refresh)
- self.druid.bind ('druid_exiting', self.JS_to_close())
-
- self += self.druid
-
- def JS_to_show (self):
- js = CTK.Dialog.JS_to_show (self)
- js += self.refresh.JS_to_load (URL_INSTALL_WELCOME)
- return js
-
-
-class Install_Stage:
- def __call__ (self):
- try:
- return self.__safe_call__()
- except Exception, e:
- # Log the exception
- exception_str = traceback.format_exc()
- print exception_str
- Install_Log.log ("EXCEPTION!\n" + exception_str)
-
- # Reset 'unfinished installations' cache
- Maintenance.Invalidate_Cache()
-
- # Present an alternative response
- cont = Exception_Handler (exception_str)
- return cont.Render().toStr()
-
-
-class Welcome (Install_Stage):
- def __safe_call__ (self):
- # Ensure the current UID has enough priviledges
- if not InstallUtil.current_UID_is_admin() and 0:
- box = CTK.Box()
- box += CTK.RawHTML ('<h2>%s</h2>' %(_(NO_ROOT_H1)))
- box += CTK.RawHTML ('<p>%s</p>' %(_(NO_ROOT_P1)))
- box += CTK.RawHTML ('<p>%s</p>' %(_(NO_ROOT_P2)))
-
- buttons = CTK.DruidButtonsPanel()
- buttons += CTK.DruidButton_Close(_('Cancel'))
- box += buttons
-
- return box.Render().toStr()
-
- # Check the rest of pre-requisites
- index = Distro.Index()
- app_id = CTK.cfg.get_val('tmp!market!install!app!application_id')
- app = index.get_package (app_id, 'software')
-
- inst = index.get_package (app_id, 'installation')
- if 'cherokee_min_ver' in inst:
- version = inst['cherokee_min_ver']
- if version_cmp (VERSION, version) < 0:
- box = CTK.Box()
- box += CTK.RawHTML ('<h2>%s</h2>' %(_(MIN_VER_H1)))
- box += CTK.RawHTML ('<p>%s</p>' %(_(MIN_VER_P1)%(locals())))
-
- buttons = CTK.DruidButtonsPanel()
- buttons += CTK.DruidButton_Close(_('Cancel'))
-
- box += buttons
- return box.Render().toStr()
-
- # Init the log file
- Install_Log.reset()
- Install_Log.log (".---------------------------------------------.")
- Install_Log.log ("| PLEASE, DO NOT EDIT OR REMOVE THIS LOG FILE |")
- Install_Log.log ("| |")
- Install_Log.log ("| It contains useful information that |")
- Install_Log.log ("| cherokee-admin might need in the future. |")
- Install_Log.log (".---------------------------------------------.")
- Install_Log.log ("Retrieving package information...")
-
- # Check whether there are CTK.cfg changes to be saved
- changes = "01"[int(CTK.cfg.has_changed())]
- CTK.cfg['tmp!market!install!cfg_previous_changes'] = changes
-
- # Render a welcome message
- box = CTK.Box()
- box += CTK.RawHTML (js = CTK.DruidContent__JS_to_goto (box.id, URL_INSTALL_DOWNLOAD))
-
- return box.Render().toStr()
-
-
-class Download (Install_Stage):
- def __safe_call__ (self):
- app_id = CTK.cfg.get_val('tmp!market!install!app!application_id')
- app_name = CTK.cfg.get_val('tmp!market!install!app!application_name')
-
- # URL Package
- index = Distro.Index()
- pkg = index.get_package (app_id, 'package')
-
- repo_url = CTK.cfg.get_val ('admin!ows!repository', REPO_MAIN)
- url_download = os.path.join (repo_url, app_id, pkg['filename'])
- CTK.cfg['tmp!market!install!download'] = url_download
-
- # Local storage shortcut
- pkg_filename_full = url_download.split('/')[-1]
- pkg_filename = pkg_filename_full.split('_')[0]
- pkg_revision = 0
-
- pkg_repo_fp = os.path.join (CHEROKEE_OWS_DIR, "packages", app_id)
- if os.access (pkg_repo_fp, os.X_OK):
- for f in os.listdir (pkg_repo_fp):
- tmp = re.findall('^%s_(\d+)'%(pkg_filename), f)
- if tmp:
- pkg_revision = max (pkg_revision, int(tmp[0]))
-
- if pkg_revision > 0:
- pkg_fullpath = os.path.join (CHEROKEE_OWS_DIR, "packages", app_id, '%s_%d.cpk' %(pkg_filename, pkg_revision))
- CTK.cfg['tmp!market!install!local_package'] = pkg_fullpath
-
- Install_Log.log ("Using local repository package: %s" %(pkg_fullpath))
-
- box = CTK.Box()
- box += CTK.RawHTML (js=CTK.DruidContent__JS_to_goto (box.id, URL_INSTALL_SETUP))
- return box.Render().toStr()
-
- # Instance a Downloader
- downloader = CTK.Downloader ('package', url_download)
- downloader.bind ('stopped', CTK.DruidContent__JS_to_close (downloader.id))
- downloader.bind ('finished', CTK.DruidContent__JS_to_goto (downloader.id, URL_INSTALL_SETUP))
- downloader.bind ('error', CTK.DruidContent__JS_to_goto (downloader.id, URL_INSTALL_DOWNLOAD_ERROR))
-
- stop = CTK.Button (_('Cancel'))
- stop.bind ('click', downloader.JS_to_stop())
- buttons = CTK.DruidButtonsPanel()
- buttons += stop
-
- Install_Log.log ("Downloading %s" %(url_download))
-
- cont = CTK.Container()
- cont += CTK.RawHTML ('<h2>%s %s</h2>' %(_("Installing"), app_name))
- cont += CTK.RawHTML ('<p>%s</p>' %(_('The application is being downloaded. Hold on tight!')))
- cont += downloader
- cont += buttons
- cont += CTK.RawHTML (js = downloader.JS_to_start())
-
- return cont.Render().toStr()
-
-
-class Download_Error (Install_Stage):
- def __safe_call__ (self):
- app_name = CTK.cfg.get_val('tmp!market!install!app!application_name')
-
- Install_Log.log ("Downloading Error: %s" %(url_download))
-
- cont = CTK.Container()
- cont += CTK.RawHTML ('<h2>%s %s</h2>' %(_("Installing"), app_name))
- cont += CTK.RawHTML (_("There was an error downloading the application. Please contact us if the problem persists."))
-
- buttons = CTK.DruidButtonsPanel()
- buttons += CTK.DruidButton_Close(_('Cancel'))
- cont += buttons
-
- return cont.Render().toStr()
-
-
-def Exception_Handler_Apply():
- # Collect information
- info = {}
- info['log'] = Install_Log.get_full_log()
- info['user'] = OWS_Login.login_user
- info['comments'] = CTK.post['comments']
- info['platform'] = SystemInfo.get_info()
- info['cfg'] = CTK.cfg.serialize()
- info['tmp!market!install'] = CTK.cfg['tmp!market!install'].serialize()
-
- # Send it
- xmlrpc = XmlRpcServer (OWS_APPS_INSTALL, user=OWS_Login.login_user, password=OWS_Login.login_password)
- install_info = xmlrpc.report_exception (info)
-
- return CTK.cfg_reply_ajax_ok()
-
-
-class Exception_Handler (CTK.Box):
- def __init__ (self, exception_str):
- CTK.Box.__init__ (self)
- self += CTK.RawHTML ('<h2 class="error-h2">%s</h2>' %(_("Internal Error")))
- self += CTK.RawHTML ('<div class="error-title">%s</div>' %(_("An internal error occurred while deploying the application")))
- self += CTK.RawHTML ('<div class="error-message">%s</div>' %(_("Information on the error has been collected so it can be reported and fixed up. Please help us improve it by sending the error information to the development team.")))
-
- thanks = CTK.Box ({'class': 'error-thanks', 'style': 'display:none'})
- thanks += CTK.RawHTML (_('Thank you for your feedback! We do appreciate it.'))
- self += thanks
-
- comments = CTK.Box()
- comments += CTK.RawHTML ('%s:' %(_("Comments")))
- comments += CTK.TextArea ({'name': 'comments', 'class': 'noauto error-comments'})
-
- submit = CTK.Submitter (URL_INSTALL_EXCEPTION)
- submit += comments
- self += submit
-
- report = CTK.Button (_('Report Issue'))
- cancel = CTK.DruidButton_Close (_('Cancel'))
- close = CTK.DruidButton_Close (_('Close'), {'style': 'display:none;'})
-
- report.bind ('click', submit.JS_to_submit())
- submit.bind ('submit_success',
- thanks.JS_to_show() + report.JS_to_hide() +
- comments.JS_to_hide() + close.JS_to_show() + cancel.JS_to_hide())
-
- buttons = CTK.DruidButtonsPanel()
- buttons += cancel
- buttons += report
- buttons += close
- self += buttons
-
-
-def _Setup_unpack():
- url_download = CTK.cfg.get_val('tmp!market!install!download')
-
- # has it been downloaded?
- pkg_filename = url_download.split('/')[-1]
-
- package_path = CTK.cfg.get_val ('tmp!market!install!local_package')
- if not package_path or not os.path.exists (package_path):
- down_entry = CTK.DownloadEntry_Factory (url_download)
- package_path = down_entry.target_path
-
- # Create the local directory
- target_path = os.path.join (CHEROKEE_OWS_ROOT, str(int(time.time()*100)))
- os.mkdir (target_path, 0700)
- CTK.cfg['tmp!market!install!root'] = target_path
-
- # Create the log file
- Install_Log.set_file (os.path.join (target_path, "install.log"))
-
- # Uncompress
- try:
- if sys.version_info < (2,5): # tarfile module prior to 2.5 is useless to us: http://bugs.python.org/issue1509889
- raise tarfile.CompressionError
-
- Install_Log.log ("Unpacking %s with Python" %(package_path))
- tar = tarfile.open (package_path, 'r:gz')
- for tarinfo in tar:
- Install_Log.log (" %s" %(tarinfo.name))
- tar.extract (tarinfo, target_path)
- ret = {'retcode': 0}
- except tarfile.CompressionError:
- command = "gzip -dc '%s' | tar xfv -" %(package_path)
- Install_Log.log ("Unpacking %(package_path)s with the GZip binary (cd: %(target_path)s): %(command)s" %(locals()))
- ret = popen.popen_sync (command, cd=target_path)
- Install_Log.log (ret['stdout'])
- Install_Log.log (ret['stderr'])
-
- # Set default permission
- Install_Log.log ("Setting default permission 755 for directory %s" %(target_path))
- os.chmod (target_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH )
-
- # Remove the package
- if package_path.startswith (CHEROKEE_OWS_DIR):
- Install_Log.log ("Skipping removal of: %s" %(package_path))
- else:
- Install_Log.log ("Removing %s" %(package_path))
- os.unlink (package_path)
-
- return ret
-
-
-class Setup (Install_Stage):
- def __safe_call__ (self):
- Install_Log.log ("Setup phase")
- app_name = CTK.cfg.get_val('tmp!market!install!app!application_name')
-
- box = CTK.Box()
- box += CTK.RawHTML ("<h2>%s %s</h2>" %(_("Installing"), app_name))
- box += CTK.RawHTML ("<h1>%s</h1>" %(_("Unpacking application…")))
-
- # Unpack
- commands = [({'function': _Setup_unpack, 'description': _("The applicaction is being unpacked…")})]
- progress = CommandProgress.CommandProgress (commands, URL_INSTALL_POST_UNPACK, props={'style': 'display:none;'})
- box += progress
- return box.Render().toStr()
-
-
-class Post_unpack (Install_Stage):
- def __safe_call__ (self):
- Install_Log.log ("Post unpack commands")
-
- target_path = CTK.cfg.get_val ('tmp!market!install!root')
- app_name = CTK.cfg.get_val ('tmp!market!install!app!application_name')
-
- # Import the Installation handler
- if os.path.exists (os.path.join (target_path, "installer.py")):
- Install_Log.log ("Passing control to installer.py")
- installer_path = os.path.join (target_path, "installer.py")
- pkg_installer = imp.load_source ('installer', installer_path)
- else:
- Install_Log.log ("Passing control to installer.pyo")
- installer_path = os.path.join (target_path, "installer.pyo")
- pkg_installer = imp.load_compiled ('installer', installer_path)
-
- # GUI
- box = CTK.Box()
-
- commands = pkg_installer.__dict__.get ('POST_UNPACK_COMMANDS',[])
- if not commands:
- box += CTK.RawHTML (js = CTK.DruidContent__JS_to_goto (box.id, URL_INSTALL_SETUP_EXTERNAL))
- return box.Render().toStr()
-
- box += CTK.RawHTML ("<h2>%s %s</h2>" %(_("Installing"), app_name))
- box += CTK.RawHTML ("<p>%s</p>" %(_("Setting it up…")))
-
- progress = CommandProgress.CommandProgress (commands, URL_INSTALL_SETUP_EXTERNAL)
- box += progress
- return box.Render().toStr()
-
-
-def Install_Done_apply():
- return CTK.cfg_reply_ajax_ok()
-
-
-class Install_Done (Install_Stage):
- def __safe_call__ (self):
- box = CTK.Box()
-
- # Automatic submit -> 'Save' button is updated.
- submit = CTK.Submitter (URL_INSTALL_DONE_APPLY)
- submit += CTK.Hidden ('foo', 'bar')
- submit.bind ('submit_success', CTK.DruidContent__JS_to_goto (box.id, URL_INSTALL_DONE_CONTENT))
-
- box += submit
- box += CTK.RawHTML (js=submit.JS_to_submit())
-
- return box.Render().toStr()
-
-
-class Install_Done_Content (Install_Stage):
- def __safe_call__ (self):
- root = CTK.cfg.get_val('tmp!market!install!root')
- app_name = CTK.cfg.get_val('tmp!market!install!app!application_name')
- cfg_changes = CTK.cfg.get_val('tmp!market!install!cfg_previous_changes')
-
- # Finished
- finished_file = os.path.join (root, "finished")
- Install_Log.log ("Creating %s" %(finished_file))
- f = open (finished_file, 'w+')
- f.close()
-
- # Normalize CTK.cfg
- CTK.cfg.normalize ('vserver')
-
- # Save configuration
- box = CTK.Box()
-
- if not int(cfg_changes):
- CTK.cfg.save()
- Install_Log.log ("Configuration saved.")
-
- Cherokee.server.restart (graceful=True)
- Install_Log.log ("Server gracefully restarted.")
- box += CTK.RawHTML (js=SaveButton.ButtonSave__JS_to_deactive())
-
- Install_Log.log ("Finished")
-
- # Thank user for the install
- box += CTK.RawHTML ('<h2>%s %s</h2>' %(app_name, _("has been installed successfully")))
- box += CTK.RawHTML ("<p>%s</p>" %(_(NOTE_THANKS_P1)))
-
- # Save / Visit
- if int(cfg_changes):
- box += CTK.Notice ('information', CTK.RawHTML (_(NOTE_SAVE_RESTART)))
-
- elif Cherokee.server.is_alive():
- install_type = CTK.cfg.get_val ('tmp!market!install!target')
- nick = CTK.cfg.get_val ('tmp!market!install!target!vserver')
- vserver_n = CTK.cfg.get_val ('tmp!market!install!target!vserver_n')
- directory = CTK.cfg.get_val ('tmp!market!install!target!directory')
-
- # Host
- if vserver_n and not nick:
- nick = CTK.cfg.get_val ("vserver!%s!nick"%(vserver_n))
-
- if not nick or nick.lower() == "default":
- sys_stats = SystemStats.get_system_stats()
- nick = sys_stats.hostname
-
- # Ports
- ports = []
- for b in CTK.cfg['server!bind'] or []:
- port = CTK.cfg.get_val ('server!bind!%s!port'%(b))
- if port:
- ports.append (port)
-
- nick_port = nick
- if ports and not '80' in ports:
- nick_port = '%s:%s' %(nick, ports[0])
-
- # URL
- url = ''
- if install_type == 'vserver' and nick:
- url = 'http://%s/'%(nick_port)
- elif install_type == 'directory' and vserver_n and directory:
- nick = CTK.cfg.get_val ('vserver!%s!nick'%(vserver_n))
- url = 'http://%s%s/'%(nick_port, directory)
-
- if url:
- box += CTK.RawHTML ('<p>%s ' %(_("You can now visit")))
- box += CTK.LinkWindow (url, CTK.RawHTML (_('your new application')))
- box += CTK.RawHTML (' on a new window.</p>')
-
- box += CTK.RawHTML ("<h1>%s</h1>" %(_(NOTE_THANKS_P2)))
-
- buttons = CTK.DruidButtonsPanel()
- buttons += CTK.DruidButton_Close(_('Close'))
- box += buttons
-
- # Clean up CTK.cfg
- for k in CTK.cfg.keys('tmp!market!install'):
- if k != 'app':
- del (CTK.cfg['tmp!market!install!%s'%(k)])
-
- return box.Render().toStr()
-
-
-CTK.publish ('^%s$'%(URL_INSTALL_WELCOME), Welcome)
-#CTK.publish ('^%s$'%(URL_INSTALL_INIT_CHECK), Init_Check)
-#CTK.publish ('^%s$'%(URL_INSTALL_PAY_CHECK), Pay_Check)
-CTK.publish ('^%s$'%(URL_INSTALL_DOWNLOAD), Download)
-CTK.publish ('^%s$'%(URL_INSTALL_SETUP), Setup)
-CTK.publish ('^%s$'%(URL_INSTALL_POST_UNPACK), Post_unpack)
-CTK.publish ('^%s$'%(URL_INSTALL_DOWNLOAD_ERROR), Download_Error)
-CTK.publish ('^%s$'%(URL_INSTALL_DONE), Install_Done)
-CTK.publish ('^%s$'%(URL_INSTALL_DONE_CONTENT), Install_Done_Content)
-CTK.publish ('^%s$'%(URL_INSTALL_DONE_APPLY), Install_Done_apply, method="POST")
-CTK.publish ('^%s$'%(URL_INSTALL_EXCEPTION), Exception_Handler_Apply, method="POST")
View
96 admin/market/InstallUtil.py
@@ -1,96 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Cherokee-admin
-#
-# Authors:
-# Alvaro Lopez Ortega <alvaro@alobbs.com>
-#
-# Copyright (C) 2001-2013 Alvaro Lopez Ortega
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of version 2 of the GNU General Public
-# License as published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.
-#
-
-import os
-import re
-import pwd
-import sys
-import SystemInfo
-
-#
-# User & Group management
-#
-
-def get_installation_UID():
- whoami = os.getuid()
-
- try:
- info = pwd.getpwuid (whoami)
- return info.pw_name
- except:
- return str(whoami)
-
-
-def get_installation_GID():
- root_group = SystemInfo.get_info()['group_root']
-
- try:
- groups = os.getgroups()
- groups.sort()
- first_group = str(groups[0])
- excep