Move main entry point in jcl.runner
darcs-hash:20071112171733-86b55-017d1391c88e8ed7e097c2696d2b8beafef79436.gz
This commit is contained in:
7
README
7
README
@@ -4,10 +4,3 @@ Jabber Component Library
|
|||||||
Present a higher level component framework for developing Jabber
|
Present a higher level component framework for developing Jabber
|
||||||
component.
|
component.
|
||||||
|
|
||||||
Here is the class the implement to create a new Jabber component (be
|
|
||||||
sure to override every methods) :
|
|
||||||
- a class inheriting from JabberComponent
|
|
||||||
- a Feeder (inheriting from Feeder)
|
|
||||||
- a Sender (inheriting from Sender)
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
34
src/jcl.py
34
src/jcl.py
@@ -1,34 +0,0 @@
|
|||||||
##
|
|
||||||
## jcl.py
|
|
||||||
## Login : David Rousselie <dax@happycoders.org>
|
|
||||||
## Started on Fri May 18 15:19:20 2007 David Rousselie
|
|
||||||
## $Id$
|
|
||||||
##
|
|
||||||
## Copyright (C) 2007 David Rousselie
|
|
||||||
## 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
|
|
||||||
## the Free Software Foundation; either version 2 of the License, or
|
|
||||||
## (at your option) any later version.
|
|
||||||
##
|
|
||||||
## 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
##
|
|
||||||
|
|
||||||
import sys
|
|
||||||
reload(sys)
|
|
||||||
sys.setdefaultencoding('utf-8')
|
|
||||||
del sys.setdefaultencoding
|
|
||||||
|
|
||||||
import jcl
|
|
||||||
from jcl.runner import JCLRunner
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
runner = JCLRunner("JCL", jcl.version)
|
|
||||||
runner.configure()
|
|
||||||
runner.run()
|
|
||||||
@@ -3,18 +3,18 @@
|
|||||||
## Login : David Rousselie <dax@happycoders.org>
|
## Login : David Rousselie <dax@happycoders.org>
|
||||||
## Started on Thu May 17 22:02:08 2007 David Rousselie
|
## Started on Thu May 17 22:02:08 2007 David Rousselie
|
||||||
## $Id$
|
## $Id$
|
||||||
##
|
##
|
||||||
## Copyright (C) 2007 David Rousselie
|
## Copyright (C) 2007 David Rousselie
|
||||||
## This program is free software; you can redistribute it and/or modify
|
## 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
|
## it under the terms of the GNU General Public License as published by
|
||||||
## the Free Software Foundation; either version 2 of the License, or
|
## the Free Software Foundation; either version 2 of the License, or
|
||||||
## (at your option) any later version.
|
## (at your option) any later version.
|
||||||
##
|
##
|
||||||
## This program is distributed in the hope that it will be useful,
|
## This program is distributed in the hope that it will be useful,
|
||||||
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
## GNU General Public License for more details.
|
## GNU General Public License for more details.
|
||||||
##
|
##
|
||||||
## You should have received a copy of the GNU General Public License
|
## You should have received a copy of the GNU General Public License
|
||||||
## along with this program; if not, write to the Free Software
|
## along with this program; if not, write to the Free Software
|
||||||
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
@@ -84,7 +84,7 @@ class JCLRunner(object):
|
|||||||
|
|
||||||
def set_attr(self, attr, value):
|
def set_attr(self, attr, value):
|
||||||
setattr(self, attr, value)
|
setattr(self, attr, value)
|
||||||
|
|
||||||
def __configure_commandline_args(self, shortopts, longopts, cleanopts):
|
def __configure_commandline_args(self, shortopts, longopts, cleanopts):
|
||||||
(opts, args) = gnu_getopt(sys.argv[1:], shortopts, longopts)
|
(opts, args) = gnu_getopt(sys.argv[1:], shortopts, longopts)
|
||||||
commandline_args = {}
|
commandline_args = {}
|
||||||
@@ -123,7 +123,7 @@ class JCLRunner(object):
|
|||||||
" from configuration file " +
|
" from configuration file " +
|
||||||
self.config_file)
|
self.config_file)
|
||||||
set_func(config_property)
|
set_func(config_property)
|
||||||
|
|
||||||
def configure(self):
|
def configure(self):
|
||||||
"""Apply configuration from command line and configuration file.
|
"""Apply configuration from command line and configuration file.
|
||||||
command line arguments override configuration file properties.
|
command line arguments override configuration file properties.
|
||||||
@@ -156,11 +156,11 @@ class JCLRunner(object):
|
|||||||
long_option = option[1]
|
long_option = option[1]
|
||||||
help += "\t-" + option[0][0] + ", --" + long_option + option[3] + "\n"
|
help += "\t-" + option[0][0] + ", --" + long_option + option[3] + "\n"
|
||||||
return help
|
return help
|
||||||
|
|
||||||
def print_help(self):
|
def print_help(self):
|
||||||
print self._get_help()
|
print self._get_help()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def get_debug(self):
|
def get_debug(self):
|
||||||
return self.__debug
|
return self.__debug
|
||||||
|
|
||||||
@@ -170,10 +170,10 @@ class JCLRunner(object):
|
|||||||
self.logger.setLevel(logging.DEBUG)
|
self.logger.setLevel(logging.DEBUG)
|
||||||
else:
|
else:
|
||||||
self.logger.setLevel(logging.CRITICAL)
|
self.logger.setLevel(logging.CRITICAL)
|
||||||
|
|
||||||
debug = property(get_debug, set_debug)
|
debug = property(get_debug, set_debug)
|
||||||
|
|
||||||
|
|
||||||
def setup_db(self):
|
def setup_db(self):
|
||||||
Account.createTable(ifNotExists=True)
|
Account.createTable(ifNotExists=True)
|
||||||
PresenceAccount.createTable(ifNotExists=True)
|
PresenceAccount.createTable(ifNotExists=True)
|
||||||
@@ -184,7 +184,7 @@ class JCLRunner(object):
|
|||||||
pidfile = open(self.pid_file, "w")
|
pidfile = open(self.pid_file, "w")
|
||||||
pidfile.write(str(os.getpid()))
|
pidfile.write(str(os.getpid()))
|
||||||
pidfile.close()
|
pidfile.close()
|
||||||
|
|
||||||
def _run(self, run_func):
|
def _run(self, run_func):
|
||||||
try:
|
try:
|
||||||
self.setup_pidfile()
|
self.setup_pidfile()
|
||||||
@@ -214,3 +214,17 @@ class JCLRunner(object):
|
|||||||
return component.run()
|
return component.run()
|
||||||
self._run(run_func)
|
self._run(run_func)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
import sys
|
||||||
|
reload(sys)
|
||||||
|
sys.setdefaultencoding('utf-8')
|
||||||
|
del sys.setdefaultencoding
|
||||||
|
import jcl
|
||||||
|
from jcl.runner import JCLRunner
|
||||||
|
runner = JCLRunner("JCL", jcl.version)
|
||||||
|
runner.configure()
|
||||||
|
runner.run()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user