[Openlanhouse-development] SF.net SVN: openlanhouse:[311] trunk
Status: Pre-Alpha
Brought to you by:
n3rd3x
|
From: <n3...@us...> - 2008-10-20 15:45:12
|
Revision: 311
http://openlanhouse.svn.sourceforge.net/openlanhouse/?rev=311&view=rev
Author: n3rd3x
Date: 2008-10-20 15:45:01 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/openlh-client/src/openlh-client
trunk/openlh-core/src/OpenlhCore/net/certgen/__init__.py
trunk/openlh-core/src/OpenlhCore/net/certgen/gnutls_certgen.py
trunk/openlh-core/src/OpenlhCore/net/certgen/openssl_certgen.py
trunk/openlh-core/src/OpenlhCore/net/client.py
trunk/openlh-core/src/OpenlhCore/net/constants.py
trunk/openlh-server/data/ui/main.ui
trunk/openlh-server/data/ui/prefs.ui
trunk/openlh-server/src/OpenlhServer/ui/main.py
trunk/openlh-server/src/openlh-server
Modified: trunk/openlh-client/src/openlh-client
===================================================================
--- trunk/openlh-client/src/openlh-client 2008-10-18 12:04:24 UTC (rev 310)
+++ trunk/openlh-client/src/openlh-client 2008-10-20 15:45:01 UTC (rev 311)
@@ -79,6 +79,7 @@
from OpenlhClient import main
from OpenlhClient.utils import rename_process, generate_id_bytime
from OpenlhClient.ui import dialogs
+from OpenlhCore.net import certgen
if os.name == 'posix':
log_normal_format = ('\033[0;33m%(name)-17s ' +
@@ -127,9 +128,12 @@
host)
else:
sys.exit(0)
+
+ def generate_keys(self):
+ """
+ Generate all keys and certificates required for execution
+ """
- def generate_privkey(self):
-
try:
os.remove(CLIENT_TLS_KEY)
except:
@@ -141,68 +145,28 @@
pass
mkdir(CERTS_PATH)
-
- try:
- import certtool
- HAS_CERTTOOL = True
- logging.debug("python-certtool found")
- except ImportError:
- HAS_CERTTOOL = False
- logging.debug("python-certtool not found")
-
- if HAS_CERTTOOL:
- USE_PY_CERTTOOL = True
- elif bool(certgen.CERTTOOL_PATH):
- USE_PY_CERTTOOL = False
- else:
- dialogs.ok_only(_('<big><b>Required Module Has Not Found</b></big>' +
- '\n\nPlease install python-certtool to run this ' +
- 'application.'),
- ICON=gtk.MESSAGE_ERROR)
-
- sys.exit(2)
try:
logging.debug("Generating Privkey")
- if USE_PY_CERTTOOL:
- privkey_obj = certtool.generate_private_key(bits=1024)
- privkey = privkey_obj.export()
- else:
- privkey = certgen.generate_private_key()
-
- open(CLIENT_TLS_KEY, 'w').write(privkey)
+ privkey = certgen.generate_private_key()
+ open(CLIENT_TLS_KEY, 'w').write(privkey.export())
- if USE_PY_CERTTOOL:
- template_obj = certtool.Template()
- template_obj.organization = _('OpenLanhouse-Client')
- template_obj.expiration_days = 1825
- template_obj.common_name = APP_NAME
-
- else:
- certdata = {'organization': _('OpenLanhouse-Client'),
- 'expiration_days': 1825,
- 'common_name': APP_NAME
- }
-
- template = certgen.create_template(**certdata)
- open(CLIENT_TLS_TEMPLATE, 'w').write(template)
+ logging.debug("Generating Template")
+ template = certgen.Template(CLIENT_TLS_TEMPLATE)
+ template.organization = _("OpenLanhouse Client")
+ template.expiration_days = 1825
- if USE_PY_CERTTOOL:
- certificate_obj = certtool.generate_self_signed(privkey=privkey_obj,
- template=template_obj,
- dig=certtool.DIG_SHA1)
- certificate = certificate_obj.export()
- else:
- certificate = certgen.generate_self_signed(CLIENT_TLS_TEMPLATE,
- CLIENT_TLS_KEY)
+ template.common_name = APP_NAME
- open(CLIENT_TLS_CERT, 'w').write(certificate)
+ logging.debug("Generating SelfSigned Certificate")
- if not USE_PY_CERTTOOL:
- os.remove(CLIENT_TLS_TEMPLATE)
+ certificate = certgen.generate_self_signed(privkey=privkey,
+ template=template)
+ open(CLIENT_TLS_CERT, 'w').write(certificate.export())
+
except Exception, error:
dialogs.ok_only(_('<big><b>Cannot Generate Private Key</b></big>' +
'\n\n%s') % str(error),
@@ -237,7 +201,7 @@
def run(self):
if not(os.path.exists(CLIENT_TLS_KEY)) or not(os.path.exists(CLIENT_TLS_CERT)):
- self.generate_privkey()
+ self.generate_keys()
app = main.Client()
self.stop_gnome_screensaver()
Modified: trunk/openlh-core/src/OpenlhCore/net/certgen/__init__.py
===================================================================
--- trunk/openlh-core/src/OpenlhCore/net/certgen/__init__.py 2008-10-18 12:04:24 UTC (rev 310)
+++ trunk/openlh-core/src/OpenlhCore/net/certgen/__init__.py 2008-10-20 15:45:01 UTC (rev 311)
@@ -17,3 +17,5 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
__all__ = ("gnutls_certgen", "openssl_certgen")
+
+from OpenlhCore.net.certgen.gnutls_certgen import * #default backend
\ No newline at end of file
Modified: trunk/openlh-core/src/OpenlhCore/net/certgen/gnutls_certgen.py
===================================================================
--- trunk/openlh-core/src/OpenlhCore/net/certgen/gnutls_certgen.py 2008-10-18 12:04:24 UTC (rev 310)
+++ trunk/openlh-core/src/OpenlhCore/net/certgen/gnutls_certgen.py 2008-10-20 15:45:01 UTC (rev 311)
@@ -16,26 +16,48 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from OpenlhCore.utils import execute_command, is_in_path
+from OpenlhCore import certtool
-CERTTOOL_PATH = is_in_path("certtool")
+class PrivateKey:
+ """
+ Private Key Object
+ """
+ def __init__(self, privkey_obj):
+ self.privkey_obj = privkey_obj
+
+ def export(self):
+ """
+ Export private key in PEM format
+ """
+ return self.privkey_obj.export()
-def generate_keys(privkey_path, selfsigned_path, template_path,
- bits, data):
+class Template(certtool.Template):
+ """
+ Template Object
+ """
+ def __init__(self, path):
+ certtool.Template.__init__(self)
+
+class SelfSigned:
+ """
+ SelfSigned Certificate
+ """
+ def __init__(self, selfsigned_obj):
+ self.selfsigned_obj = selfsigned_obj
- if not CERTTOOL_PATH:
- raise SystemError("certtool is not installed, please install it")
+ def export(self):
+ """
+ Export self-signed Certificate in PEM format
+ """
+ return self.selfsigned_obj.export()
+
+def generate_private_key(bits=1024):
+ privkey_obj = certtool.generate_private_key(bits=bits)
+ return PrivateKey(privkey_obj)
+
+def generate_self_signed(privkey, template):
+ certificate = certtool.generate_self_signed(privkey=privkey.privkey_obj,
+ template=template,
+ dig=certtool.DIG_SHA1)
- cmd = [CERTTOOL_PATH, "--generate-privkey", "--bits", str(bits)]
-
- (stdout, stderr, retval) = execute_command(cmd)
-
- if retval != 0:
- raise SystemError(stderr)
- else:
- print stdout, stderr, retval
-
- print "Certtool:%s\nPrivkey:%s\nSelfSigned:%s\nTemplate:%s\nBits:%d\n" % (CERTTOOL_PATH, privkey_path,
- selfsigned_path,
- template_path,
- bits)
+ return SelfSigned(certificate)
\ No newline at end of file
Modified: trunk/openlh-core/src/OpenlhCore/net/certgen/openssl_certgen.py
===================================================================
--- trunk/openlh-core/src/OpenlhCore/net/certgen/openssl_certgen.py 2008-10-18 12:04:24 UTC (rev 310)
+++ trunk/openlh-core/src/OpenlhCore/net/certgen/openssl_certgen.py 2008-10-20 15:45:01 UTC (rev 311)
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2008 Wilson Pinto J\xFAnior <wi...@op...>
+# Copyright (C) 2008 Wilson Pinto Júnior <wi...@op...>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Modified: trunk/openlh-core/src/OpenlhCore/net/client.py
===================================================================
--- trunk/openlh-core/src/OpenlhCore/net/client.py 2008-10-18 12:04:24 UTC (rev 310)
+++ trunk/openlh-core/src/OpenlhCore/net/client.py 2008-10-20 15:45:01 UTC (rev 311)
@@ -261,7 +261,6 @@
#headers
if data.startswith('-----'):
-
try:
data = self.handle_headers(data)
except Exception, error:
Modified: trunk/openlh-core/src/OpenlhCore/net/constants.py
===================================================================
--- trunk/openlh-core/src/OpenlhCore/net/constants.py 2008-10-18 12:04:24 UTC (rev 310)
+++ trunk/openlh-core/src/OpenlhCore/net/constants.py 2008-10-20 15:45:01 UTC (rev 311)
@@ -39,5 +39,5 @@
XMLRequestRegex = re.compile(r'-----BEGIN XMLREQUEST'
r' ID=(?P<id>\d+) SIZE=(?P<size>\d+)-----(?P<data>(.*))')
-SendFileRegex = re.compile(r'-----BEGIN SENDFILE METHOD=(?P<method>[\w.]+) '
+SendFileRegex = re.compile(r'-----BEGIN SENDFILE ID=(?P<id>\d+) METHOD=(?P<method>[\w._]+) '
r'SIZE=(?P<size>\d+)-----(?P<data>(.*))')
\ No newline at end of file
Modified: trunk/openlh-server/data/ui/main.ui
===================================================================
--- trunk/openlh-server/data/ui/main.ui 2008-10-18 12:04:24 UTC (rev 310)
+++ trunk/openlh-server/data/ui/main.ui 2008-10-20 15:45:01 UTC (rev 311)
@@ -494,7 +494,7 @@
</child>
<child>
<object class="GtkAction" id="ticket_menuitem">
- <property name="visible">False</property>
+ <property name="visible">True</property>
<property name="stock_id">gtk-new</property>
<property name="name">ticket_menuitem</property>
<property name="label" translatable="yes">_Ticket</property>
Modified: trunk/openlh-server/data/ui/prefs.ui
===================================================================
--- trunk/openlh-server/data/ui/prefs.ui 2008-10-18 12:04:24 UTC (rev 310)
+++ trunk/openlh-server/data/ui/prefs.ui 2008-10-20 15:45:01 UTC (rev 311)
@@ -236,7 +236,7 @@
</child>
<child>
<object class="GtkCheckButton" id="ticket_suport">
- <property name="visible">False</property>
+ <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Ticket support</property>
Modified: trunk/openlh-server/src/OpenlhServer/ui/main.py
===================================================================
--- trunk/openlh-server/src/OpenlhServer/ui/main.py 2008-10-18 12:04:24 UTC (rev 310)
+++ trunk/openlh-server/src/OpenlhServer/ui/main.py 2008-10-20 15:45:01 UTC (rev 311)
@@ -63,6 +63,8 @@
self.gconf_client = gconf.client_get_default()
self.gconf_client.add_dir('/apps/openlh-server',
gconf.CLIENT_PRELOAD_NONE)
+ self.gconf_client.notify_add("/apps/openlh-server/ticket_suport",
+ self.on_ticket_suport_cb)
self.icons = icons.Icons()
self.status_icons = icons.Icons(icon_path=STATUS_ICON_PATH)
@@ -2104,3 +2106,14 @@
dlg = PluginsWindow(MainWindow=self, Daemon=self.daemon,
Parent=self.mainwindow)
dlg.run()
+
+ def on_ticket_suport_cb(self, client, cnxn_id, entry, what):
+ value = entry.get_value().get_bool()
+ ui_manager3 = self.xml.get_object("uimanager3")
+
+ widget = ui_manager3.get_widget('ticket_menuitem')
+
+ if value:
+ widget.show()
+ else:
+ widget.hide()
Modified: trunk/openlh-server/src/openlh-server
===================================================================
--- trunk/openlh-server/src/openlh-server 2008-10-18 12:04:24 UTC (rev 310)
+++ trunk/openlh-server/src/openlh-server 2008-10-20 15:45:01 UTC (rev 311)
@@ -26,10 +26,11 @@
disable_autodebug = False
verbose = False
+debug_color = "auto"
try:
- opts, args = getopt.getopt(sys.argv[1:], 'hvp:', ['help', 'verbose',
- 'disable-autoverbose', 'version'])
+ opts, args = getopt.getopt(sys.argv[1:], 'hvp:', ['help', 'verbose=',
+ 'version', 'debugcolor='])
except getopt.error, msg:
print msg
@@ -39,19 +40,31 @@
for o, a in opts:
if o in ('-h', '--help'):
- print sys.argv[0], '[--help] [--verbose] [--disable-autoverbose] [--version]'
+ print sys.argv[0], '[--help] [--verbose] [--debugcolor] [--version]'
sys.exit()
elif o == '--verbose':
+
verbose = False
+
+ if a == "on":
+ verbose = True
+ disable_autodebug = False
+ elif a == "off":
+ verbose = False
+ disable_autodebug = True
+ else:
+ disable_autodebug = False
- elif o == '--disable-autoverbose':
- disable_autodebug = True
-
elif o == '--version':
print APP_NAME, APP_VERSION
sys.exit()
+
+ if o == '--debugcolor':
+ debug_color = a
+ else:
+ debug_color = "auto"
try:
import pygtk
@@ -76,23 +89,25 @@
sys.exit(3)
from time import strftime
-from OpenlhServer import daemon, certgen
+from OpenlhServer import daemon
from OpenlhServer.utils import rename_process, mkdir, md5_cripto, pid_alive
from OpenlhServer.ui import dialogs, main
+from OpenlhCore.net import certgen
+
# Check ANSI colors, only available in POSIX
-if os.name == 'posix':
+if (debug_color == "auto" and os.name == 'posix') or debug_color=="on":
log_normal_format = ('\033[0;33m%(name)-17s '
'\033[0;31m%(levelname)-8s '
- '\033[0;37m%(message)s')
+ '\033[0;37m%(message)s\033[0m')
log_debug_format = ('\033[0;32m%(asctime)s '
'\033[0;31m%(levelname)-6s '
'\033[0;33m%(name)-17s '
- '\033[0;37m%(message)s')
+ '\033[40;1;37m%(message)s\033[0m')
else:
- log_normal_format = '%(name)-14s %(levelname)-8s %(message)s'
- log_debug_format = '%(asctime)s (levelname)-6s (name)-17s (message)s'
+ log_normal_format = ('%(name)-17s %(levelname)-8s %(message)s')
+ log_debug_format = ('%(asctime)s %(levelname)-6s %(name)-17s %(message)s')
log_format = log_normal_format
log_level = logging.CRITICAL
@@ -156,7 +171,10 @@
self.gconf_client.set_float("/apps/openlh-server/price_per_hour",
self.price_per_hour)
- def generate_privkey(self):
+ def generate_keys(self):
+ """
+ Generate all keys and certificates required for execution
+ """
try:
os.remove(SERVER_TLS_KEY)
@@ -169,75 +187,31 @@
pass
mkdir(CERTS_PATH)
-
- try:
- import certtool
- HAS_CERTTOOL = True
- logging.debug("python-certtool found")
- except ImportError:
- HAS_CERTTOOL = False
- logging.debug("python-certtool not found")
-
- if HAS_CERTTOOL:
- USE_PY_CERTTOOL = True
- elif bool(certgen.CERTTOOL_PATH):
- USE_PY_CERTTOOL = False
- else:
- dialogs.ok_only(_('<big><b>Required Module Has Not Found</b></big>'
- '\n\nPlease install python-certtool to run this '
- 'application.'),
- ICON=gtk.MESSAGE_ERROR)
-
- sys.exit(2)
try:
logging.debug("Generating Privkey")
- if USE_PY_CERTTOOL:
- privkey_obj = certtool.generate_private_key(bits=1024)
- privkey = privkey_obj.export()
- else:
- privkey = certgen.generate_private_key()
-
- open(SERVER_TLS_KEY, 'w').write(privkey)
+ privkey = certgen.generate_private_key()
+ open(SERVER_TLS_KEY, 'w').write(privkey.export())
- if USE_PY_CERTTOOL:
- template_obj = certtool.Template()
- template_obj.organization = self.name
- template_obj.expiration_days = 1825
-
- if self.admin_email:
- template_obj.email = self.admin_email
-
- template_obj.common_name = APP_NAME
-
- else:
- certdata = {'organization': self.name,
- 'expiration_days': 1825,
- 'common_name': APP_NAME
- }
-
- if self.admin_email:
- certdata['email'] = self.admin_email
-
- template = certgen.create_template(**certdata)
- open(SERVER_TLS_TEMPLATE, 'w').write(template)
+ logging.debug("Generating Template")
+ template = certgen.Template(SERVER_TLS_TEMPLATE)
+ template.organization = self.name
+ template.expiration_days = 1825
- if USE_PY_CERTTOOL:
- certificate_obj = certtool.generate_self_signed(privkey=privkey_obj,
- template=template_obj,
- dig=certtool.DIG_SHA1)
- certificate = certificate_obj.export()
- else:
- certificate = certgen.generate_self_signed(SERVER_TLS_TEMPLATE,
- SERVER_TLS_KEY)
+ if self.admin_email:
+ template.email = self.admin_email
- open(SERVER_TLS_CERT, 'w').write(certificate)
+ template.common_name = APP_NAME
- if not USE_PY_CERTTOOL:
- os.remove(SERVER_TLS_TEMPLATE)
+ logging.debug("Generating SelfSigned Certificate")
+ certificate = certgen.generate_self_signed(privkey=privkey,
+ template=template)
+
+ open(SERVER_TLS_CERT, 'w').write(certificate.export())
+
except Exception, error:
dialogs.ok_only(_('<big><b>Cannot Generate Private Key</b></big>' +
'\n\n%s') % str(error),
@@ -258,7 +232,7 @@
def run(self):
if not(os.path.exists(SERVER_TLS_KEY)) or not(os.path.exists(SERVER_TLS_CERT)):
- self.generate_privkey()
+ self.generate_keys()
appdaemon = daemon.Server()
appgui = main.Manager(appdaemon)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|