Changeset - 46ed8c369e66
[Not reviewed]
3 1 0
Lance Edgar (lance) - 3 years ago 2021-12-23 12:31:23
lance@edbob.org
Remove deprecated "dbsync" logic

that has been superseded by "datasync" for years now...
4 files changed with 0 insertions and 505 deletions:
0 comments (0 inline, 0 general)
rattail/commands/core.py
Show inline comments
 
@@ -546,135 +546,96 @@ class EmailBouncer(Subcommand):
 
        parser.add_argument('-p', '--pidfile', metavar='PATH', default='/var/run/rattail/bouncer.pid',
 
                            help="Path to PID file.")
 
        parser.add_argument('--daemonize', action='store_true',
 
                            help="DEPRECATED")
 
        parser.add_argument('--no-daemonize',
 
                            '-D', '--do-not-daemonize',
 
                            action='store_false', dest='daemonize',
 
                            help="DEPRECATED")
 

	
 
    def run(self, args):
 
        from rattail.bouncer.daemon import BouncerDaemon
 

	
 
        daemon = BouncerDaemon(args.pidfile, config=self.config)
 
        if args.subcommand == 'stop':
 
            daemon.stop()
 
        else: # start
 
            try:
 
                daemon.start(daemonize=False)
 
            except KeyboardInterrupt:
 
                self.stderr.write("Interrupted.\n")
 

	
 

	
 
class DateOrganize(Subcommand):
 
    """
 
    Organize files in a given directory, according to date
 
    """
 
    name = 'date-organize'
 
    description = __doc__.strip()
 

	
 
    def add_parser_args(self, parser):
 
        parser.add_argument('folder', metavar='PATH',
 
                            help="Path to directory containing files which are "
 
                            "to be organized by date.")
 

	
 
    def run(self, args):
 
        today = datetime.date.today()
 
        for filename in sorted(os.listdir(args.folder)):
 
            path = os.path.join(args.folder, filename)
 
            if os.path.isfile(path):
 
                mtime = datetime.datetime.fromtimestamp(os.path.getmtime(path))
 
                if mtime.date() < today:
 
                    datedir = mtime.strftime(os.sep.join(('%Y', '%m', '%d')))
 
                    datedir = os.path.join(args.folder, datedir)
 
                    if not os.path.exists(datedir):
 
                        os.makedirs(datedir)
 
                    shutil.move(path, datedir)
 

	
 

	
 
class DatabaseSyncCommand(Subcommand):
 
    """
 
    Controls the database synchronization service.
 
    """
 

	
 
    name = 'dbsync'
 
    description = "Manage the database synchronization service"
 

	
 
    def add_parser_args(self, parser):
 
        subparsers = parser.add_subparsers(title='subcommands')
 

	
 
        start = subparsers.add_parser('start', help="Start service")
 
        start.set_defaults(subcommand='start')
 
        stop = subparsers.add_parser('stop', help="Stop service")
 
        stop.set_defaults(subcommand='stop')
 

	
 
        if sys.platform == 'linux2':
 
            parser.add_argument('-p', '--pidfile',
 
                                help="Path to PID file", metavar='PATH')
 
            parser.add_argument('-D', '--do-not-daemonize',
 
                                action='store_false', dest='daemonize', default=True,
 
                                help="Do not daemonize when starting.")
 

	
 
    def run(self, args):
 
        from rattail.db.sync import linux as dbsync
 

	
 
        if args.subcommand == 'start':
 
            try:
 
                dbsync.start_daemon(self.config, args.pidfile, args.daemonize)
 
            except KeyboardInterrupt:
 
                if not args.daemonize:
 
                    self.stderr.write("Interrupted.\n")
 
                else:
 
                    raise
 

	
 
        elif args.subcommand == 'stop':
 
            dbsync.stop_daemon(self.config, args.pidfile)
 

	
 

	
 
class Dump(Subcommand):
 
    """
 
    Do a simple data dump.
 
    """
 

	
 
    name = 'dump'
 
    description = "Dump data to file."
 

	
 
    def add_parser_args(self, parser):
 
        parser.add_argument(
 
            '--output', '-o', metavar='FILE',
 
            help="Optional path to output file.  If none is specified, "
 
            "data will be written to standard output.")
 
        parser.add_argument(
 
            'model', help="Model whose data will be dumped.")
 

	
 
    def get_model(self):
 
        """
 
        Returns the module which contains all relevant data models.
 

	
 
        By default this returns ``rattail.db.model``, but this method may be
 
        overridden in derived commands to add support for extra data models.
 
        """
 
        from rattail.db import model
 
        return model
 

	
 
    def run(self, args):
 
        from rattail.db import Session
 
        from rattail.db.dump import dump_data
 

	
 
        model = self.get_model()
 
        if hasattr(model, args.model):
 
            cls = getattr(model, args.model)
 
        else:
 
            self.stderr.write("Unknown model: {0}\n".format(args.model))
 
            sys.exit(1)
 

	
 
        progress = None
 
        if self.show_progress: # pragma no cover
 
            progress = ConsoleProgress
 

	
 
        if args.output:
 
            output = open(args.output, 'wb')
 
        else:
 
            output = self.stdout
 

	
 
        session = Session()
 
        dump_data(session, cls, output, progress=progress)
rattail/db/sync/__init__.py
Show inline comments
 
deleted file
rattail/db/sync/linux.py
Show inline comments
 
deleted file
rattail/db/sync/win32.py
Show inline comments
 
deleted file
0 comments (0 inline, 0 general)