Exemplo n.º 1
0
    def _restore(cls, args, credential):
        """
           Execute All restore operations
        """
        LOG.critical("Connect to Gmail server.\n")
        # Create a gmvault releaving read_only_access
        restorer = gmvault.GMVaulter(args['db-dir'], args['host'], args['port'], \
                                       args['email'], credential, read_only_access = False)

        #full sync is the first one
        if args.get('type', '') == 'full':

            #call restore
            labels = [args['apply_label']] if args['apply_label'] else []
            restorer.restore(extra_labels = labels, restart = args['restart'], \
                             emails_only = args['emails_only'], chats_only = args['chats_only'])

        elif args.get('type', '') == 'quick':

            #take the last two to 3 months depending on the current date

            # today - 2 months
            today = datetime.date.today()
            begin = today - datetime.timedelta(
                gmvault_utils.get_conf_defaults().getint(
                    "Restore", "quick_days", 8))

            starting_dir = gmvault_utils.get_ym_from_datetime(begin)

            #call restore
            labels = [args['apply_label']] if args['apply_label'] else []
            restorer.restore(pivot_dir = starting_dir, extra_labels = labels, restart = args['restart'], \
                             emails_only = args['emails_only'], chats_only = args['chats_only'])

        else:
            raise ValueError(
                "Unknown synchronisation mode %s. Please use full (default), quick."
            )

        #print error report
        LOG.critical(restorer.get_operation_report())
Exemplo n.º 2
0
 def _restore(cls, args, credential):
     """
        Execute All restore operations
     """
     LOG.critical("Connect to Gmail server.\n")
     # Create a gmvault releaving read_only_access
     restorer = gmvault.GMVaulter(args['db-dir'], args['host'], args['port'], \
                                    args['email'], credential, read_only_access = False)
     
     #full sync is the first one
     if args.get('type', '') == 'full':
         
         #call restore
         labels = [args['apply_label']] if args['apply_label'] else []
         restorer.restore(extra_labels = labels, restart = args['restart'], \
                          emails_only = args['emails_only'], chats_only = args['chats_only'])
         
     elif args.get('type', '') == 'quick':
         
         #take the last two to 3 months depending on the current date
         
         # today - 2 months
         today = datetime.date.today()
         begin = today - datetime.timedelta(gmvault_utils.get_conf_defaults().getint("Restore", "quick_days", 8))
         
         starting_dir = gmvault_utils.get_ym_from_datetime(begin)
         
         #call restore
         labels = [args['apply_label']] if args['apply_label'] else []
         restorer.restore(pivot_dir = starting_dir, extra_labels = labels, restart = args['restart'], \
                          emails_only = args['emails_only'], chats_only = args['chats_only'])
     
     else:
         raise ValueError("Unknown synchronisation mode %s. Please use full (default), quick.")
     
     #print error report
     LOG.critical(restorer.get_operation_report())