Changeset 1113 for pykota

Show
Ignore:
Timestamp:
07/29/03 22:55:17 (21 years ago)
Author:
jalet
Message:

1.14 is out !

Location:
pykota/trunk
Files:
12 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/edpykota

    r1105 r1113  
    2323# 
    2424# $Log$ 
     25# Revision 1.56  2003/07/29 20:55:17  jalet 
     26# 1.14 is out ! 
     27# 
    2528# Revision 1.55  2003/07/28 09:11:12  jalet 
    2629# PyKota now tries to add its attributes intelligently in existing LDAP 
     
    538541                      
    539542if __name__ == "__main__" :  
     543    retcode = 0 
    540544    try : 
    541545        defaults = { \ 
     
    584588            raise PyKotaToolError, _("incompatible options, see help.") 
    585589        else : 
    586             sys.exit(editor.main(args, options)) 
     590            retcode = editor.main(args, options) 
    587591    except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError), msg :             
    588592        sys.stderr.write("%s\n" % msg) 
    589593        sys.stderr.flush() 
    590         sys.exit(-1) 
    591  
     594        retcode = -1 
     595 
     596    try : 
     597        editor.storage.close() 
     598    except (TypeError, NameError, AttributeError) :     
     599        pass 
     600         
     601    sys.exit(retcode)     
  • pykota/trunk/bin/pykota

    r1080 r1113  
    2323# 
    2424# $Log$ 
     25# Revision 1.37  2003/07/29 20:55:17  jalet 
     26# 1.14 is out ! 
     27# 
    2528# Revision 1.36  2003/07/10 06:09:52  jalet 
    2629# Incorrect documentation string 
     
    232235            return -1 
    233236             
    234 def main() :     
     237def main(thefilter) :     
    235238    """Do it, and do it right !""" 
    236     # Initializes the current tool 
    237     kotafilter = PyKotaFilter()     
    238      
    239239    # 
    240240    # If this is a CUPS filter, we should act and die like a CUPS filter when needed 
    241     if kotafilter.printingsystem == "CUPS" : 
     241    if thefilter.printingsystem == "CUPS" : 
    242242        if len(sys.argv) not in (6, 7) :     
    243243            sys.stderr.write("ERROR: %s job-id user title copies options [file]\n" % sys.argv[0]) 
    244             return kotafilter.removeJob() 
     244            return thefilter.removeJob() 
    245245     
    246246    # Get the last page counter and last username from the Quota Storage backend 
    247     printer = kotafilter.storage.getPrinter(kotafilter.printername) 
     247    printer = thefilter.storage.getPrinter(thefilter.printername) 
    248248    if not printer.Exists : 
    249249        # The printer is unknown from the Quota Storage perspective 
    250250        # we let the job pass through, but log a warning message 
    251         kotafilter.logger.log_message(_("Printer %s not registered in the PyKota system") % kotafilter.printername, "warn") 
     251        thefilter.logger.log_message(_("Printer %s not registered in the PyKota system") % thefilter.printername, "warn") 
    252252    else :     
    253         user = kotafilter.storage.getUser(kotafilter.username) 
     253        user = thefilter.storage.getUser(thefilter.username) 
    254254        if not user.Exists : 
    255255            # The user is unknown from the Quota Storage perspective 
     
    257257            # either let the job pass through or reject it, but we 
    258258            # log a message in any case. 
    259             policy = kotafilter.config.getPrinterPolicy(kotafilter.printername) 
     259            policy = thefilter.config.getPrinterPolicy(thefilter.printername) 
    260260            if policy == "ALLOW" : 
    261261                action = "POLICY_ALLOW" 
    262262            else :     
    263263                action = "POLICY_DENY" 
    264             kotafilter.logger.log_message(_("User %s not registered in the PyKota system, applying default policy (%s) for printer %s") % (kotafilter.username, action, kotafilter.printername), "warn") 
     264            thefilter.logger.log_message(_("User %s not registered in the PyKota system, applying default policy (%s) for printer %s") % (thefilter.username, action, thefilter.printername), "warn") 
    265265            if action == "POLICY_DENY" : 
    266                 return kotafilter.removeJob() 
     266                return thefilter.removeJob() 
    267267        else : 
    268268            # Now does the accounting and act depending on the result 
    269             action = kotafilter.accounter.doAccounting(printer, user) 
     269            action = thefilter.accounter.doAccounting(printer, user) 
    270270             
    271271            # if not allowed to print then die, else proceed. 
    272272            if action == "DENY" : 
    273273                # No, just die cleanly 
    274                 return kotafilter.removeJob() 
     274                return thefilter.removeJob() 
    275275         
    276276    # pass the job untouched to the underlying layer 
    277     kotafilter.accounter.filterInput(kotafilter.inputfile)       
     277    thefilter.accounter.filterInput(thefilter.inputfile)       
    278278     
    279     return kotafilter.acceptJob() 
     279    return thefilter.acceptJob() 
    280280 
    281281if __name__ == "__main__" :     
    282282    retcode = -1 
    283283    try : 
    284         retcode = main() 
     284        # Initializes the current tool 
     285        kotafilter = PyKotaFilter()     
     286        retcode = main(kotafilter) 
    285287    except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError, PyKotaAccounterError, AttributeError, KeyError, IndexError, ValueError, IOError), msg : 
    286288        sys.stderr.write("ERROR : PyKota filter failed (%s)\n" % msg) 
    287289        sys.stderr.flush() 
     290        retcode = -1 
     291 
     292    try : 
     293        kotafilter.storage.close() 
     294    except (TypeError, NameError, AttributeError) :     
     295        pass 
     296         
    288297    sys.exit(retcode)     
    289      
  • pykota/trunk/bin/pykotme

    r1099 r1113  
    2323# 
    2424# $Log$ 
     25# Revision 1.3  2003/07/29 20:55:17  jalet 
     26# 1.14 is out ! 
     27# 
    2528# Revision 1.2  2003/07/25 10:41:29  jalet 
    2629# Better documentation. 
     
    150153         
    151154if __name__ == "__main__" :  
     155    retcode = 0 
    152156    try : 
    153157        defaults = { \ 
     
    173177            sender.display_version_and_quit() 
    174178        else : 
    175             sys.exit(sender.main(args, options)) 
     179            retcode = sender.main(args, options) 
    176180    except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError), msg :             
    177181        sys.stderr.write("%s\n" % msg) 
    178182        sys.stderr.flush() 
    179         sys.exit(-1) 
     183        retcode = -1 
    180184 
     185    try : 
     186        sender.storage.close() 
     187    except (TypeError, NameError, AttributeError) :     
     188        pass 
     189         
     190    sys.exit(retcode)     
  • pykota/trunk/bin/repykota

    r1071 r1113  
    2323# 
    2424# $Log$ 
     25# Revision 1.42  2003/07/29 20:55:17  jalet 
     26# 1.14 is out ! 
     27# 
    2528# Revision 1.41  2003/07/07 12:19:52  jalet 
    2629# Now repykota and warnpykota --groups check the groups the user is a member of 
     
    287290            raise PyKotaToolError, _("incompatible options, see help.") 
    288291        else : 
    289             sys.exit(reportTool.main(args, options)) 
     292            retcode = reportTool.main(args, options) 
    290293    except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError, PyKotaReporterError), msg :             
    291294        sys.stderr.write("%s\n" % msg) 
    292295        sys.stderr.flush() 
    293         sys.exit(-1) 
    294  
     296        retcode = -1  
     297 
     298    try : 
     299        reportTool.storage.close() 
     300    except (TypeError, NameError, AttributeError) :     
     301        pass 
     302         
     303    sys.exit(retcode)     
  • pykota/trunk/bin/warnpykota

    r1071 r1113  
    2323# 
    2424# $Log$ 
     25# Revision 1.22  2003/07/29 20:55:17  jalet 
     26# 1.14 is out ! 
     27# 
    2528# Revision 1.21  2003/07/07 12:19:52  jalet 
    2629# Now repykota and warnpykota --groups check the groups the user is a member of 
     
    199202                      
    200203if __name__ == "__main__" :  
     204    retcode = 0 
    201205    try : 
    202206        defaults = { \ 
     
    226230            raise PyKotaToolError, _("incompatible options, see help.") 
    227231        else : 
    228             sys.exit(sender.main(args, options)) 
     232            retcode = sender.main(args, options) 
    229233    except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError), msg :             
    230234        sys.stderr.write("%s\n" % msg) 
    231235        sys.stderr.flush() 
    232         sys.exit(-1) 
    233  
     236        retcode = -1 
     237         
     238    try : 
     239        sender.storage.close() 
     240    except (TypeError, NameError, AttributeError) :     
     241        pass 
     242         
     243    sys.exit(retcode)     
  • pykota/trunk/cgi-bin/printquota.cgi

    r1054 r1113  
    2323# 
    2424# $Log$ 
     25# Revision 1.12  2003/07/29 20:55:17  jalet 
     26# 1.14 is out ! 
     27# 
    2528# Revision 1.11  2003/07/01 12:37:31  jalet 
    2629# Nicer UI 
     
    179182    admin.guiAction() 
    180183    admin.guiDisplay() 
     184 
     185    try : 
     186        admin.storage.close() 
     187    except (TypeError, NameError, AttributeError) :     
     188        pass 
     189         
     190    sys.exit(0) 
  • pykota/trunk/NEWS

    r1111 r1113  
    2222PyKota NEWS : 
    2323 
     24    - 1.14 :  
     25     
     26        - The PostgreSQL database connection is now always closed before 
     27          exit. The LDAP database connection too, but it didn't suffer 
     28          from the problem anyway, AFAICT. 
     29         
    2430    - 1.14beta2 : 
    2531     
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1112 r1113  
    2121# 
    2222# $Log$ 
     23# Revision 1.24  2003/07/29 20:55:17  jalet 
     24# 1.14 is out ! 
     25# 
    2326# Revision 1.23  2003/07/29 19:52:32  jalet 
    2427# Forgot to read the email field from LDAP 
     
    143146             
    144147    def __del__(self) :         
     148        """Ensures that the database connection is closed.""" 
     149        self.close() 
     150         
     151    def close(self) :     
    145152        """Closes the database connection.""" 
    146153        if not self.closed : 
  • pykota/trunk/pykota/storages/pgstorage.py

    r1087 r1113  
    2121# 
    2222# $Log$ 
     23# Revision 1.11  2003/07/29 20:55:17  jalet 
     24# 1.14 is out ! 
     25# 
    2326# Revision 1.10  2003/07/16 21:53:08  jalet 
    2427# Really big modifications wrt new configuration file's location and content. 
     
    9093             
    9194    def __del__(self) :         
     95        """Ensures that the database connection is closed.""" 
     96        self.close() 
     97         
     98    def close(self) :     
    9299        """Closes the database connection.""" 
    93100        if not self.closed : 
  • pykota/trunk/pykota/tool.py

    r1091 r1113  
    2121# 
    2222# $Log$ 
     23# Revision 1.49  2003/07/29 20:55:17  jalet 
     24# 1.14 is out ! 
     25# 
    2326# Revision 1.48  2003/07/21 23:01:56  jalet 
    2427# Modified some messages aout soft limit 
     
    234237        self.smtpserver = self.config.getSMTPServer() 
    235238         
     239    def clean(self) :     
     240        """Ensures that the database is closed.""" 
     241        try : 
     242            self.storage.close() 
     243        except (TypeError, NameError, AttributeError) :     
     244            pass 
     245             
    236246    def display_version_and_quit(self) : 
    237247        """Displays version number, then exists successfully.""" 
     248        self.clean() 
    238249        print version.__version__ 
    239250        sys.exit(0) 
     
    241252    def display_usage_and_quit(self) : 
    242253        """Displays command line usage, then exists successfully.""" 
     254        self.clean() 
    243255        print self.documentation 
    244256        sys.exit(0) 
  • pykota/trunk/pykota/version.py

    r1111 r1113  
    2121# 
    2222 
    23 __version__ = "1.14beta2_unofficial" 
     23__version__ = "1.14_unofficial" 
    2424 
    2525__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng.""" 
  • pykota/trunk/setup.py

    r1111 r1113  
    2323# 
    2424# $Log$ 
     25# Revision 1.23  2003/07/29 20:55:17  jalet 
     26# 1.14 is out ! 
     27# 
    2528# Revision 1.22  2003/07/29 09:54:03  jalet 
    2629# Added configurable LDAP mail attribute support 
     
    271274    sys.stdout.write("DATABASE SCHEMA USING initscripts/postgresql/upgrade-to-1.14.sql\n") 
    272275    sys.stdout.write("PLEASE READ DOCUMENTATION IN initscripts/postgresql/ TO LEARN HOW TO DO.\n") 
     276    sys.stdout.write("YOU CAN DO THAT AFTER THE INSTALLATION IS FINISHED, OR PRESS CTRL+C NOW.\n") 
    273277    sys.stdout.write("\n\nYOU DON'T HAVE ANYTHING SPECIAL TO DO IF THIS IS YOUR FIRST INSTALLATION.\n\n") 
    274278    dummy = raw_input("Please press ENTER when you have read the message above. ")