コード例 #1
0
def run(user, start_page=1):
    batch = Batch()
    batch.owner = user

    #generator = yaml.load_all(open('delayed_test.yaml'))
    #all_entries = list(generator)
    all_preds = []
    for actid in good_acts:
        all_preds.extend(
            cn3.Predicate.objects.filter(sentence__activity__id=actid,
                                         language=en))
    paginator = Paginator(all_preds, 100)
    #pages = ((i,paginator.page(i)) for i in range(start_page,paginator.num_pages))

    @transaction.commit_on_success
    def do_batch(entries):
        for entry in entries:
            try:
                preds = process_predicate(entry, batch)
            # changed to an improbable exception for now
            except ZeroDivisionError, e:
                # Add entry
                e.entry = entry

                # Extract traceback
                e_type, e_value, e_tb = sys.exc_info()
                e.tb = "\n".join(
                    traceback.format_exception(e_type, e_value, e_tb))

                # Raise again
                raise e
コード例 #2
0
def run(user, start_page=1):
    batch = Batch()
    batch.owner = user
    
    #generator = yaml.load_all(open('delayed_test.yaml'))
    #all_entries = list(generator)
    all_preds = []
    for actid in good_acts:
        all_preds.extend(cn3.Predicate.objects.filter(sentence__activity__id=actid, language=en))
    paginator = Paginator(all_preds,100)
    #pages = ((i,paginator.page(i)) for i in range(start_page,paginator.num_pages))

    @transaction.commit_on_success
    def do_batch(entries):
        for entry in entries:
            try:
                preds = process_predicate(entry, batch)
            # changed to an improbable exception for now
            except ZeroDivisionError, e:
                # Add entry
                e.entry = entry

                # Extract traceback
                e_type, e_value, e_tb = sys.exc_info()
                e.tb = "\n".join(traceback.format_exception( e_type, e_value, e_tb ))

                # Raise again
                raise e
コード例 #3
0
ファイル: build.py プロジェクト: wrapperband/conceptnet
def run(user, lang, start_page=1):
    batch = Batch()
    batch.owner = user
    
    #generator = yaml.load_all(open('delayed_test.yaml'))
    #all_entries = list(generator)
    all_entries = pickle.load(open('yamlparsed.pickle'))
    paginator = Paginator(all_entries,100)
    #pages = ((i,paginator.page(i)) for i in range(start_page,paginator.num_pages))

    @transaction.commit_on_success
    def do_batch(entries):
        for entry in entries:
            try:
                preds = process_yaml(entry, lang, batch)
            # changed to an improbable exception for now
            except ZeroDivisionError, e:
                # Add entry
                e.entry = entry

                # Extract traceback
                e_type, e_value, e_tb = sys.exc_info()
                e.tb = "\n".join(traceback.format_exception( e_type, e_value, e_tb ))

                # Raise again
                raise e