Esempio n. 1
0
    def get(self):
        """
        Demonstrates using a background thread to change the global
        val from 'Dog' to 'Cat'

        The auto GET parameter determines whether to start the thread
        automatically or manually
        """
        auto = self.request.get('auto')

        # [START gae_runtime]
        # sample function to run in a background thread
        def change_val(arg):
            global val
            val = arg

        if auto:
            # Start the new thread in one command
            background_thread.start_new_background_thread(change_val, ['Cat'])
        else:
            # create a new thread and start it
            t = background_thread.BackgroundThread(target=change_val,
                                                   args=['Cat'])
            t.start()
        # [END gae_runtime]

        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write('Done')
Esempio n. 2
0
 def get(self):
     log.info('Starting Hourly Analytic Thread')
     t = background_thread.BackgroundThread(
         target=self._process_hourly_analytics)
     t.start()
     # self._process_hourly_analytics()
     log.info('Thread Started')
 def post(self):
     data_all = sys.stdin
     loggger.info(data_all)
     # html=""
     # iter_html = przm_batchmodel.loop_html(thefile)
     t = background_thread.BackgroundThread(target=przm_batchoutput.przmBatchOutputPage, args=[thefile])
     t.start()
Esempio n. 4
0
    def post(self):
        if not self.user.is_super_admin:
            raise HttpErrorException.not_found()
        if self.json_request.get('clear_indexes'):
            orgs = Organization.query().fetch()
            for org in orgs:
                indexes = org.get_indexes()
                for index in indexes:
                    ttindex.clear_index(index)

            users = User.query(User.organization == None).fetch()
            for user in users:
                indexes = user.get_indexes()
                for index in indexes:
                    ttindex.clear_index(index)

        project_ids = self.json_request.get('project_ids')
        if project_ids:
            if project_ids == 'all':
                self.project_keys = Project.query().fetch(keys_only=True)
            else:
                if type(project_ids) is not list:
                    raise HttpErrorException.bad_request(
                        'project ids must be list')

                for pro_id in project_ids:
                    pro = Project.get_by_id(pro_id)

                    if not pro:
                        raise HttpErrorException.bad_request(
                            'invalid project id given: ' + str(pro_id))
                    self.project_keys.append(pro.key)

            t = background_thread.BackgroundThread(target=self.index_project)
            t.start()
Esempio n. 5
0
    def get(self, script=None):
        log.info('Background request received %s' % script)
        if not self.user.is_super_admin:
            raise HttpErrorException.not_found()
        if script == 'migration':
            log.info('Starting migration thread')
            t = background_thread.BackgroundThread(target=_do_migration)
            t.start()
            log.info('Started migration thread')
        log.info('Background request ended')


# if parent.children.index(concept.key) == 0:
#     return_status = False
#     if parent.node_type == 'Concept':
#         attributes = ndb.get_multi(parent.attributes)
#         for attr in attributes:
#             if 'ul' in attr.attributes or 'ol' in attr.attributes:
#                 if 'ul' in attr.attributes:
#                     attr.attributes.remove('ul')
#                     if len(concept.attributes) > 0:
#                         concept.attributes[0].attributes.append('ul')
#                     else:
#                         concept.attributes.append(Attributes(
#                             key=Attributes.create_key(), project=project.key,
#                             document=project.distilled_document.key, attributes=['ul']).put()
#                         )
#                 if 'ol' in attr.attributes:
#                     attr.attributes.remove('ol')
#                     if len(concept.attributes) > 0:
#                         concept.attributes[0].attributes.append('ol')
#                     else:
#                         concept.attributes.append(Attributes(
#                             key=Attributes.create_key(), project=project.key,
#                             document=project.distilled_document.key, attributes=['ol']).put()
#                         )
#                 attr.put()
#                 if len(attr.attributes) == 0:
#                     attr.key.delete()
#                     parent.attributes.remove(attr.key)
#                     attributes.remove(attr)
#                 children = parent.children[1:]
#                 parent.children = [parent.children[0]]
#                 parent.put()
#                 if not concept.children or len(concept.children) == 0:
#                     concept.children = children
#                 else:
#                     concept.children += children
#                 for child in children:
#                     child.parent = concept.key
#                     child.put()
#                 break
#         ndb.put_multi(attributes)
Esempio n. 6
0
 def get(self):
     log.info('Starting Spectra Daily Points Distribution')
     t = background_thread.BackgroundThread(target=self._distribute_spectra_points())
     t.start()
Esempio n. 7
0
 def get(self):
     runtime.set_shutdown_hook(shutdown)
     thread = background_thread.BackgroundThread(
         target=counter_loop)
     thread.start()
Esempio n. 8
0
 def get(self):
     log.info('Starting Hourly Analytic Generator')
     t = background_thread.BackgroundThread(target=self._gen_analytics())
     t.start()
Esempio n. 9
0
 def get(self):
     t = background_thread.BackgroundThread(target=self._run)
     t.start()
Esempio n. 10
0
 def get(self):
     t = background_thread.BackgroundThread(target=self._start_health_monitoring)
     t.start()
def start_account_notification():
    t = background_thread.BackgroundThread(target=run)
    t.start()