Changeset 2432

Show
Ignore:
Timestamp:
09/08/05 20:56:44 (19 years ago)
Author:
jerome
Message:

pkturnkey now simulates by default, instead of modifying the database.
The --dryrun command line switch was replaced by the --force command line
switch, which does exactly the opposite : allows the database to be modified.
Now pkturnkey sends all the informations about what it does to the
screen (but on stderr).
Severity : now you can play with this without risking to loose your datas :-)

Location:
pykota/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pkturnkey

    r2420 r2432  
    4747  -h | --help          Prints this message then exits. 
    4848   
    49   -d | --dryrun        Doesn't modify the database at all, but instead prints 
    50                        what it would do. 
     49  -f | --force         Modifies the database instead of printing what 
     50                       it would do. 
    5151                        
    5252  -u | --uidmin uid    Only adds users whose uid is greater than or equal to 
     
    6464  $ pkturnkey --uidmin jerome 
    6565 
    66   Will initialize PyKota's database will all existing printers and 
    67   create print accounts for all users whose uid is greater than or 
    68   equal to jerome's one. 
     66  Will simulate the initialization of PyKota's database will all existing 
     67  printers and print accounts for all users whose uid is greater than 
     68  or equal to jerome's one. 
     69  To REALLY initialize the database instead of simulating it, please 
     70  use the -f | --force command line switch. 
    6971""") 
    7072         
     
    7375    def listPrinters(self) : 
    7476        """Returns a list of tuples (queuename, deviceuri) for all existing print queues.""" 
    75         self.logdebug("Extracting all print queues.") 
     77        self.printInfo("Extracting all print queues.") 
    7678        result = os.popen("lpstat -v", "r") 
    7779        lines = result.readlines() 
     
    8789    def listUsers(self, uidmin, uidmax) :     
    8890        """Returns a list of usernames whose uids are between uidmin and uidmax.""" 
    89         self.logdebug("Extracting all users whose uid is between %s and %s." % (uidmin, uidmax)) 
     91        self.printInfo("Extracting all users whose uid is between %s and %s." % (uidmin, uidmax)) 
    9092        return [entry[0] for entry in pwd.getpwall() if uidmin <= entry[2] <= uidmax] 
    9193         
    9294    def runCommand(self, command, dryrun) :     
    9395        """Launches an external command.""" 
    94         if dryrun : 
    95             self.printInfo("%s" % command) 
    96         else :     
    97             self.logdebug("%s" % command) 
     96        self.printInfo("%s" % command) 
     97        if not dryrun :     
    9898            os.system(command) 
    9999             
     
    121121        if not names : 
    122122            names = ["*"] 
     123             
     124        self.printInfo("Please be patient...") 
     125        dryrun = not options["force"] 
     126        if dryrun : 
     127            self.printInfo("Don't worry, the database WILL NOT BE MODIFIED.") 
     128        else :     
     129            self.printInfo("Please WORRY NOW, the database WILL BE MODIFIED.") 
    123130             
    124131        if not options["uidmin"] :     
     
    144151                except KeyError, msg :     
    145152                    raise PyKotaToolError, _("Unknown username %s : %s") % (options["uidmax"], msg) 
    146                      
     153         
    147154        if uidmin > uidmax :             
    148155            (uidmin, uidmax) = (uidmax, uidmin) 
     
    150157        printers = self.listPrinters()                     
    151158         
    152         print "Please be patient..." 
    153          
    154159        if printers : 
    155             self.createPrinters(printers, options["dryrun"]) 
    156             self.createUsers(users, options["dryrun"]) 
    157          
    158         print "Database initialized." 
     160            self.createPrinters(printers, dryrun) 
     161            self.createUsers(users, dryrun) 
     162         
     163        if dryrun : 
     164            self.printInfo("Simulation terminated.") 
     165        else :     
     166            self.printInfo("Database initialized !") 
    159167                     
    160168                      
     
    162170    retcode = 0 
    163171    try : 
    164         short_options = "hvdu:U:" 
    165         long_options = ["help", "version", "dryrun", "uidmin=", "uidmax="] 
     172        short_options = "hvfu:U:" 
     173        long_options = ["help", "version", "force", "uidmin=", "uidmax="] 
    166174         
    167175        # Initializes the command line tool 
     
    178186        options["help"] = options["h"] or options["help"] 
    179187        options["version"] = options["v"] or options["version"] 
    180         options["dryrun"] = options["d"] or options["dryrun"] 
     188        options["force"] = options["f"] or options["force"] 
    181189        options["uidmin"] = options["u"] or options["uidmin"] 
    182190        options["uidmax"] = options["U"] or options["uidmax"] 
  • pykota/trunk/NEWS

    r2425 r2432  
    2222PyKota NEWS : 
    2323        
     24    - 1.23alpha27 : 
     25     
     26        - Replaced the --dryrun command line option by the --force 
     27          command line option in pkturnkey, with exactly the opposite 
     28          effect (for security reasons). 
     29           
    2430    - 1.23alpha26 : 
    2531     
  • pykota/trunk/pykota/version.py

    r2425 r2432  
    2222# 
    2323 
    24 __version__ = "1.23alpha26_unofficial" 
     24__version__ = "1.23alpha27_unofficial" 
    2525 
    2626__doc__ = "PyKota : a complete Printing Quota Solution for CUPS and LPRng."