<s> from __future__ import absolute_import <EOL> from __future__ import print_function <EOL> from optparse import make_option <EOL> from django . core . management . base import BaseCommand <EOL> from zerver . models import get_realm , Message , Realm , Stream , Recipient <EOL> import datetime <EOL> import time <EOL> class Command ( BaseCommand ) : <EOL> default_cutoff = time . time ( ) - <NUM_LIT> * <NUM_LIT> * <NUM_LIT> * <NUM_LIT:30> <EOL> option_list = BaseCommand . option_list + ( <EOL> make_option ( '<STR_LIT>' , <EOL> dest = '<STR_LIT>' , <EOL> type = '<STR_LIT:str>' , <EOL> help = '<STR_LIT>' ) , <EOL> make_option ( '<STR_LIT>' , <EOL> dest = '<STR_LIT>' , <EOL> type = '<STR_LIT:int>' , <EOL> default = default_cutoff , <EOL> help = '<STR_LIT>' ) <EOL> ) <EOL> def handle ( self , * args , ** options ) : <EOL> realm = get_realm ( options [ "<STR_LIT>" ] ) <EOL> streams = Stream . objects . filter ( realm = realm , invite_only = False ) <EOL> recipients = Recipient . objects . filter ( <EOL> type = Recipient . STREAM , type_id__in = [ stream . id for stream in streams ] ) <EOL> cutoff = datetime . datetime . fromtimestamp ( options [ "<STR_LIT>" ] ) <EOL> messages = Message . objects . filter ( pub_date__gt = cutoff , recipient__in = recipients ) <EOL> for message in messages : <EOL> print ( message . to_dict ( False ) ) </s>
