<s> """<STR_LIT>""" <EOL> import sys <EOL> import logging <EOL> from modularodm import Q <EOL> from website . app import init_app <EOL> from website import models <EOL> from scripts import utils as script_utils <EOL> from framework . transactions . context import TokuTransaction <EOL> logger = logging . getLogger ( __name__ ) <EOL> def date_updated ( node ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> return node . logs [ - <NUM_LIT:1> ] . date <EOL> except IndexError : <EOL> return node . date_created <EOL> def main ( dry = True ) : <EOL> init_app ( routes = False ) <EOL> nodes = models . Node . find ( Q ( '<STR_LIT>' , '<STR_LIT>' , None ) ) <EOL> node_count = nodes . count ( ) <EOL> count = <NUM_LIT:0> <EOL> errored_nodes = [ ] <EOL> for node in nodes : <EOL> count += <NUM_LIT:1> <EOL> with TokuTransaction ( ) : <EOL> node . date_modified = date_updated ( node ) <EOL> if not dry : <EOL> try : <EOL> node . save ( ) <EOL> except KeyError as error : <EOL> logger . error ( '<STR_LIT>' ) <EOL> logger . exception ( error ) <EOL> errored_nodes . append ( node ) <EOL> else : <EOL> logger . info ( '<STR_LIT>' . format ( count , node_count , node . _id ) ) <EOL> if errored_nodes : <EOL> logger . error ( '<STR_LIT>' . format ( len ( errored_nodes ) ) ) <EOL> logger . error ( '<STR_LIT:\n>' . join ( [ each . _id for each in errored_nodes ] ) ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> dry_run = '<STR_LIT>' in sys . argv <EOL> if not dry_run : <EOL> script_utils . add_file_logger ( logger , __file__ ) <EOL> main ( dry = dry_run ) </s>
