[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Git][ftp-team/dak][master] queue_rss.py: switch to Python 3



Title: GitLab

Ansgar pushed to branch master at Debian FTP Team / dak

Commits:

1 changed file:

Changes:

  • tools/queue_rss.py
    1
    -#!/usr/bin/python
    
    1
    +#!/usr/bin/python3
    
    2 2
     # Generate two rss feeds for a directory with .changes file
    
    3 3
     
    
    4 4
     # License: GPL v2 or later
    
    5 5
     # Author: Filippo Giunchedi <filippo@debian.org>
    
    6 6
     # Version: 0.5
    
    7 7
     
    
    8
    -from __future__ import print_function
    
    9
    -
    
    10 8
     import cgi
    
    11 9
     import os
    
    12 10
     import os.path
    
    13
    -import cPickle
    
    11
    +import pickle
    
    14 12
     import re
    
    15 13
     import sys
    
    16 14
     import time
    
    ... ... @@ -209,7 +207,12 @@ if __name__ == "__main__":
    209 207
         status_db = os.path.join(settings.datadir, db_filename)
    
    210 208
     
    
    211 209
         try:
    
    212
    -        status = cPickle.load(open(status_db))
    
    210
    +        with open(status_db, 'rb') as fh:
    
    211
    +            try:
    
    212
    +                status = pickle.load(fh, encoding="utf-8")
    
    213
    +            except UnicodeDecodeError:
    
    214
    +                fh.seek(0)
    
    215
    +                status = pickle.load(fh, encoding="latin-1")
    
    213 216
         except IOError:
    
    214 217
             status = Status()
    
    215 218
     
    
    ... ... @@ -233,7 +236,8 @@ if __name__ == "__main__":
    233 236
         status.queue = current_queue
    
    234 237
     
    
    235 238
         try:
    
    236
    -        cPickle.dump(status, open(status_db, "w+"))
    
    239
    +        with open(status_db, 'wb+') as fh:
    
    240
    +            pickle.dump(status, fh)
    
    237 241
         except IOError as why:
    
    238 242
             print("Unable to save status:", why, file=sys.stderr)
    
    239 243
             sys.exit(1)
    


  • Reply to: