Overview
Comment: | bigger buffers, default to nntp, support for slashes |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | master | trunk |
Files: | files | file ages | folders |
SHA3-256: |
7513432477d9b16754054da926cb1402 |
User & Date: | arcade on 2018-10-28 15:18:12.375 |
Other Links: | branch diff | manifest | tags |
Context
2018-10-28
| ||
15:18 | bigger buffers, default to nntp, support for slashes Leaf check-in: 7513432477 user: arcade tags: master, trunk | |
2016-09-17
| ||
06:32 | other files check-in: 865f55448c user: arcade@b1t.name tags: master, trunk | |
Changes
Modified nntpdup.py
from [ef47497ce9]
to [8a165713ed].
1 2 3 | #!/usr/bin/env python3 import configparser, email.utils, getpass, imaplib, nntplib, re, sqlite3, sys | | | | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #!/usr/bin/env python3 import configparser, email.utils, getpass, imaplib, nntplib, re, sqlite3, sys imaplib._MAXLINE = 1024 * 1024 * 4 nntplib._MAXLINE = 1024 * 1024 * 4 config = configparser.ConfigParser(allow_no_value = True) config.read('nntpdup.conf') try: #server = nntplib.NNTP_SSL(config['connection']['newsserver']) server = nntplib.NNTP(config['connection']['newsserver']) except nntplib.NNTPTemporaryError as err: if err.response.startswith('400 load at '): print(err.response) exit(0) else: raise(err) mserver = imaplib.IMAP4_SSL(config['connection']['mailserver']) |
︙ | ︙ | |||
161 162 163 164 165 166 167 | else: print('Message id not found.') print(repr(data)) exit(1) if (count % 1000) == 0: sys.stdout.write('.') sys.stdout.flush() | | > | > > > > | | | | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | else: print('Message id not found.') print(repr(data)) exit(1) if (count % 1000) == 0: sys.stdout.write('.') sys.stdout.flush() print('], deleted:', deleted) folder.sync() mserver.expunge() folder = Folder('nntpdup.sqlite') limits = [0, 0] limitSteps = [headerLimit / len(config['groups']), mailLimit / len(config['groups'])] maxlength = 0 for folderName in (config['groups'].keys()): maxlength = max(maxlength, len(folderName)) skew = 1 + int(maxlength / 8) for folderName in (set(config['groups'].keys())): stats = [0, 0] folder.select(folderName) localFolderName = folderName resp = mserver.select(localFolderName) print('#--', localFolderName, ':', resp) if resp[0] != 'OK': localFolderName = folderName.replace('.', '/') resp = mserver.select(localFolderName) if resp[0] != 'OK': print("Can't open folder.") exit(1) if int(resp[1][0]) != folder.count: check_folder(mserver, folder, localFolderName) _, count, first, last, _ = server.group(folderName) limits[0] += limitSteps[0] if last > folder.last: count = 0 # we need to fetch new ids request = min(last, folder.last + limits[0]) |
︙ | ︙ | |||
267 268 269 270 271 272 273 | out.append(line.decode('ascii', 'ignore')) except UnicodeDecodeError: print(repr(line)) exit(1) out.append('\n') try: #print('*', item, date, type(date)) | | | | | | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | out.append(line.decode('ascii', 'ignore')) except UnicodeDecodeError: print(repr(line)) exit(1) out.append('\n') try: #print('*', item, date, type(date)) mserver.append(localFolderName, None, date, b'\n'.join(info.lines)) except AttributeError as err: #print('*', item, raw_date, repr(date)) #raise(err) mserver.append(localFolderName, None, backup_date, b'\n'.join(info.lines)) except OverflowError as err: #print('*', item, raw_date, repr(date)) #raise(err) mserver.append(localFolderName, None, backup_date, b'\n'.join(info.lines)) else: #print('*', item, env_date, type(env_date)) mserver.append(localFolderName, None, env_date, b'\n'.join(info.lines)) folder.addmail(item) folder.sync() count += 1 if count >= limits[1]: break except nntplib.NNTPTemporaryError as err: if err.response.startswith('430 No such article'): |
︙ | ︙ |