Changeset 3294 for pykota/trunk/bin

Show
Ignore:
Timestamp:
01/18/08 23:39:41 (16 years ago)
Author:
jerome
Message:

Added modules to store utility functions and application
intialization code, which has nothing to do in classes.
Modified tool.py accordingly (far from being finished)
Use these new modules where necessary.
Now converts all command line arguments to unicode before
beginning to work. Added a proper logging method for already
encoded query strings.

Location:
pykota/trunk/bin
Files:
18 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/autopykota

    r3288 r3294  
    2525import sys 
    2626import os 
     27 
     28import pykota.appinit 
     29from pykota.utils import * 
    2730 
    2831from pykota.errors import PyKotaToolError, PyKotaCommandLineError 
     
    140143            retcode = automat.main(args, options) 
    141144    except KeyboardInterrupt :         
    142         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     145        logerr("\nInterrupted with Ctrl+C !\n") 
    143146        retcode = -3 
    144147    except PyKotaCommandLineError, msg :     
    145         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     148        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    146149        retcode = -2 
    147150    except SystemExit :         
  • pykota/trunk/bin/cupspykota

    r3288 r3294  
    4343 
    4444from mx import DateTime 
     45 
     46import pykota.appinit 
     47from pykota.utils import * 
    4548 
    4649from pykota.errors import PyKotaToolError 
     
    13131316        sys.exit(0)                 
    13141317    elif len(sys.argv) not in (6, 7) :     
    1315         sys.stderr.write("ERROR: %s job-id user title copies options [file]\n"\ 
     1318        logerr("ERROR: %s job-id user title copies options [file]\n"\ 
    13161319                              % sys.argv[0]) 
    13171320        sys.exit(1) 
  • pykota/trunk/bin/dumpykota

    r3288 r3294  
    2323 
    2424import sys 
     25 
     26import pykota.appinit 
     27from pykota.utils import * 
    2528 
    2629from pykota.errors import PyKotaCommandLineError 
     
    183186            retcode = dumper.main(args, options) 
    184187    except KeyboardInterrupt :         
    185         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     188        logerr("\nInterrupted with Ctrl+C !\n") 
    186189        retcode = -3 
    187190    except PyKotaCommandLineError, msg :     
    188         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     191        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    189192        retcode = -2 
    190193    except SystemExit :         
  • pykota/trunk/bin/edpykota

    r3288 r3294  
    2323 
    2424import sys 
     25 
     26import pykota.appinit 
     27from pykota.utils import * 
    2528 
    2629from pykota.errors import PyKotaCommandLineError 
     
    352355            retcode = manager.main(args, options) 
    353356    except KeyboardInterrupt :         
    354         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     357        logerr("\nInterrupted with Ctrl+C !\n") 
    355358        retcode = -3 
    356359    except PyKotaCommandLineError, msg :      
    357         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     360        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    358361        retcode = -2 
    359362    except SystemExit :         
  • pykota/trunk/bin/pkbanner

    r3288 r3294  
    4444    hasPIL = True 
    4545     
     46import pykota.appinit 
     47from pykota.utils import * 
     48 
    4649from pykota.errors import PyKotaToolError, PyKotaCommandLineError 
    4750from pykota.tool import Tool, crashed, N_ 
     
    325328            retcode = banner.main(args, options) 
    326329    except KeyboardInterrupt :         
    327         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     330        logerr("\nInterrupted with Ctrl+C !\n") 
    328331        retcode = -3 
    329332    except PyKotaCommandLineError, msg :     
    330         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     333        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    331334        retcode = -2 
    332335    except SystemExit :         
  • pykota/trunk/bin/pkbcodes

    r3288 r3294  
    2525import sys 
    2626import pwd 
     27 
     28import pykota.appinit 
     29from pykota.utils import * 
    2730 
    2831from pykota.errors import PyKotaCommandLineError 
     
    199202            retcode = manager.main(args, options) 
    200203    except KeyboardInterrupt :         
    201         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     204        logerr("\nInterrupted with Ctrl+C !\n") 
    202205        retcode = -3 
    203206    except PyKotaCommandLineError, msg :     
    204         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     207        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    205208        retcode = -2 
    206209    except SystemExit :         
  • pykota/trunk/bin/pkinvoice

    r3288 r3294  
    4343else :     
    4444    hasPIL = True 
     45 
     46import pykota.appinit 
     47from pykota.utils import * 
    4548 
    4649from pykota.errors import PyKotaToolError, PyKotaCommandLineError 
     
    403406            retcode = invoiceGenerator.main(args, options) 
    404407    except KeyboardInterrupt :         
    405         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     408        logerr("\nInterrupted with Ctrl+C !\n") 
    406409        retcode = -3 
    407410    except PyKotaCommandLineError, msg :      
    408         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     411        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    409412        retcode = -2 
    410413    except SystemExit :         
  • pykota/trunk/bin/pkmail

    r3288 r3294  
    3030from email.Header import Header 
    3131import email.Utils 
     32 
     33import pykota.appinit 
     34from pykota.utils import * 
    3235 
    3336from pykota.errors import PyKotaCommandLineError 
     
    164167            retcode = mailparser.main(args, options) 
    165168    except KeyboardInterrupt :         
    166         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     169        logerr("\nInterrupted with Ctrl+C !\n") 
    167170        retcode = -3 
    168171    except PyKotaCommandLineError, msg :     
    169         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     172        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    170173        retcode = -2 
    171174    except SystemExit :         
  • pykota/trunk/bin/pknotify

    r3288 r3294  
    3434else :     
    3535    hasPAM = True 
     36 
     37import pykota.appinit 
     38from pykota.utils import * 
    3639 
    3740from pykota.errors import PyKotaToolError, PyKotaCommandLineError 
     
    354357            retcode = notifier.main(args, options) 
    355358    except KeyboardInterrupt :         
    356         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     359        logerr("\nInterrupted with Ctrl+C !\n") 
    357360        retcode = -3 
    358361    except PyKotaCommandLineError, msg :     
    359         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     362        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    360363        print "CANCEL"  # Forces the cancellation of the print job if a command line switch is incorrect 
    361364        retcode = -2 
  • pykota/trunk/bin/pkprinters

    r3288 r3294  
    2525import sys 
    2626import pwd 
     27 
     28import pykota.appinit 
     29from pykota.utils import * 
    2730 
    2831from pykota.errors import PyKotaCommandLineError 
     
    372375            retcode = manager.main(args, options) 
    373376    except KeyboardInterrupt :         
    374         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     377        logerr("\nInterrupted with Ctrl+C !\n") 
    375378        retcode = -3 
    376379    except PyKotaCommandLineError, msg :     
    377         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     380        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    378381        retcode = -2 
    379382    except SystemExit :         
  • pykota/trunk/bin/pkrefund

    r3288 r3294  
    4343else :     
    4444    hasPIL = True 
     45 
     46import pykota.appinit 
     47from pykota.utils import * 
    4548 
    4649from pykota.errors import PyKotaToolError, PyKotaCommandLineError 
     
    440443            retcode = refundmanager.main(args, options) 
    441444    except KeyboardInterrupt :         
    442         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     445        logerr("\nInterrupted with Ctrl+C !\n") 
    443446        retcode = -3 
    444447    except PyKotaCommandLineError, msg :     
    445         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     448        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    446449        retcode = -2 
    447450    except SystemExit :         
  • pykota/trunk/bin/pksetup

    r3290 r3294  
    408408        homedirectory = self.addPyKotaUser() 
    409409        if homedirectory is None : 
    410             sys.stderr.write("Installation can't proceed. You MUST create a system user named 'pykota'.\n") 
     410            logerr("Installation can't proceed. You MUST create a system user named 'pykota'.\n") 
    411411        else :     
    412412            self.upgradeSystem() 
     
    465465            installer = globals()[classname]() 
    466466        except KeyError :     
    467             sys.stderr.write("There's currently no support for the %s distribution, sorry.\n" % sys.argv[1]) 
     467            logerr("There's currently no support for the %s distribution, sorry.\n" % sys.argv[1]) 
    468468            retcode = -1 
    469469        else :     
     
    471471                retcode = installer.setup() 
    472472            except KeyboardInterrupt :              
    473                 sys.stderr.write("\n\n\nWARNING : Setup was aborted at user's request !\n\n") 
     473                logerr("\n\n\nWARNING : Setup was aborted at user's request !\n\n") 
    474474                retcode = -1 
    475475    sys.exit(retcode) 
  • pykota/trunk/bin/pkturnkey

    r3288 r3294  
    2929import signal 
    3030 
     31import pykota.appinit 
     32from pykota.utils import * 
     33 
    3134from pykota.errors import PyKotaToolError, PyKotaCommandLineError 
    3235from pykota.tool import Tool, crashed, N_ 
     
    226229                from pysnmp.proto.api import alpha 
    227230            except ImportError :     
    228                 sys.stderr.write("pysnmp doesn't seem to be installed. SNMP checks will be ignored !\n") 
     231                logerr("pysnmp doesn't seem to be installed. SNMP checks will be ignored !\n") 
    229232                return 0 
    230233        else :         
     
    528531            retcode = manager.main(args, options) 
    529532    except KeyboardInterrupt :         
    530         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     533        logerr("\nInterrupted with Ctrl+C !\n") 
    531534        retcode = -3 
    532535    except PyKotaCommandLineError, msg :     
    533         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     536        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    534537        retcode = -2 
    535538    except SystemExit :         
  • pykota/trunk/bin/pkusers

    r3288 r3294  
    2525import pwd 
    2626import grp 
     27 
     28import pykota.appinit 
     29from pykota.utils import * 
    2730 
    2831from pykota.errors import PyKotaCommandLineError 
     
    440443            retcode = manager.main(args, options) 
    441444    except KeyboardInterrupt :         
    442         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     445        logerr("\nInterrupted with Ctrl+C !\n") 
    443446        retcode = -3 
    444447    except PyKotaCommandLineError, msg :     
    445         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     448        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    446449        retcode = -2 
    447450    except SystemExit :         
  • pykota/trunk/bin/pykosd

    r3288 r3294  
    3030    import pyosd 
    3131except ImportError :     
    32     sys.stderr.write("Sorry ! You need both xosd and the Python OSD library (pyosd) for this software to work.\n") 
     32    logerr("Sorry ! You need both xosd and the Python OSD library (pyosd) for this software to work.\n") 
    3333    sys.exit(-1) 
     34 
     35import pykota.appinit 
     36from pykota.utils import * 
    3437 
    3538from pykota.errors import PyKotaToolError, PyKotaCommandLineError 
     
    192195        retcode = 0 
    193196    except KeyboardInterrupt :         
    194         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     197        logerr("\nInterrupted with Ctrl+C !\n") 
    195198        retcode = -3 
    196199    except PyKotaCommandLineError, msg :     
    197         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     200        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    198201        retcode = -2 
    199202    except SystemExit :         
  • pykota/trunk/bin/pykotme

    r3288 r3294  
    2525import os 
    2626import pwd 
     27 
     28import pykota.appinit 
     29from pykota.utils import * 
    2730 
    2831from pykota.errors import PyKotaCommandLineError 
     
    156159            retcode = sender.main(args, options) 
    157160    except KeyboardInterrupt :         
    158         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     161        logerr("\nInterrupted with Ctrl+C !\n") 
    159162        retcode = -3 
    160163    except PyKotaCommandLineError, msg :     
    161         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     164        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    162165        retcode = -2 
    163166    except SystemExit :         
  • pykota/trunk/bin/repykota

    r3288 r3294  
    2727 
    2828from mx import DateTime 
     29 
     30import pykota.appinit 
     31from pykota.utils import * 
    2932 
    3033from pykota.errors import PyKotaToolError, PyKotaCommandLineError 
     
    157160            retcode = reportTool.main(args, options) 
    158161    except KeyboardInterrupt :         
    159         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     162        logerr("\nInterrupted with Ctrl+C !\n") 
    160163        retcode = -3 
    161164    except PyKotaCommandLineError, msg :     
    162         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     165        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    163166        retcode = -2 
    164167    except SystemExit :         
  • pykota/trunk/bin/warnpykota

    r3288 r3294  
    2525import os 
    2626import pwd 
     27 
     28import pykota.appinit 
     29from pykota.utils import * 
    2730 
    2831from pykota.errors import PyKotaCommandLineError 
     
    156159            retcode = sender.main(args, options) 
    157160    except KeyboardInterrupt :         
    158         sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     161        logerr("\nInterrupted with Ctrl+C !\n") 
    159162        retcode = -3 
    160163    except PyKotaCommandLineError, msg :     
    161         sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
     164        logerr("%s : %s\n" % (sys.argv[0], msg)) 
    162165        retcode = -2 
    163166    except SystemExit :