Ejemplo n.º 1
0
class ProtobufHandler(webapp2.RequestHandler):
    def __init__(self, request=None, response=None):
        webapp2.RequestHandler.__init__(self, request, response)
        if self.request.get('debug', False):
            self.response.headers['Content-type'] = 'text/plain'
        else:
            self.response.headers['Content-type'] = 'binary/octet-stream'


app = webapp2.WSGIApplication(
    [
        webapp2.Route('/', 'main.MainHandler'),
        webapp2.Route('/faq', 'main.FaqHandler'),
        webapp2.Route('/login', 'route.login.LoginHandler'),
        routes.PathPrefixRoute('/flowerbed', [
            webapp2.Route('/explore', 'route.flowerbed.FlowerbedExploreHandler'),
            webapp2.Route('/add', 'route.flowerbed.FlowerbedAddHandler'),
            webapp2.Route('/transfer', 'route.flowerbed.FlowerbedTransferHandler'),
        ]),
        routes.PathPrefixRoute('/possession', [
            webapp2.Route('/list', 'route.possession.PossessionListHandler'),
            webapp2.Route('/lost', 'route.possession.PossessionLostHandler'),
        ]),
        routes.PathPrefixRoute('/bookmark', [
            webapp2.Route('/list', 'route.bookmark.BookmarkListHandler'),
            webapp2.Route('/add', 'route.bookmark.BookmarkAddHandler'),
            webapp2.Route('/remove', 'route.bookmark.BookmarkRemoveHandler'),
        ]),
        webapp2.Route('/update/<table:[^?]+>', 'admin.update.UpdateHandler'),
    ],debug=DEBUG)
Ejemplo n.º 2
0
        elif not isinstance(blockable, binary_models.Binary):
            self.abort(httplib.BAD_REQUEST, explanation='Must be a Binary')

        force_installer = self.request.get('value', None)
        if force_installer is None:
            self.abort(httplib.BAD_REQUEST,
                       explanation='No installer state provided')

        new_policy = (constants.RULE_POLICY.FORCE_INSTALLER
                      if force_installer.lower() == 'true' else
                      constants.RULE_POLICY.FORCE_NOT_INSTALLER)

        new_installer_state = self._SetInstallerPolicy(blockable_id,
                                                       new_policy)
        self.respond_json(new_installer_state)


# The Webapp2 routes defined for these handlers.
ROUTES = routes.PathPrefixRoute('/blockables', [
    webapp2.Route('/<package_id>/contents', handler=PackageContentsHandler),
    webapp2.Route('/<blockable_id>/pending-state-change',
                  handler=PendingStateChangeHandler),
    webapp2.Route('/<blockable_id>/pending-installer-state-change',
                  handler=(PendingInstallerStateChangeHandler)),
    webapp2.Route('/<blockable_id>/installer-state',
                  handler=SetInstallerStateHandler),
    webapp2.Route('/<blockable_id>', handler=BlockableHandler),
    webapp2.Route('/<platform>/<blockable_type>',
                  handler=BlockableQueryHandler),
])
Ejemplo n.º 3
0
# Google's AppEngine modules:
import webapp2
from webapp2 import Route
from webapp2_extras import routes
from webapp2_extras.routes import DomainRoute

# Controllers and handlers
from controller.location_status import *
from controller.location_status_search_api import *

# Requested URLs that are not listed here,
# will return 404

ROUTES = [
    DomainRoute(
        '<:(localhost|vulgusapp\.appspot\.com)>',
        [
            routes.PathPrefixRoute(
                r'/api/1',
                [

                    # Location endpoints
                    Route(r'/location_status',
                          handler=LocationStatusController),
                    Route(r'/location_status_search',
                          handler=LocationStatusSearchController)
                ])
        ])
]

app = webapp2.WSGIApplication(ROUTES, debug=False)
Ejemplo n.º 4
0
      blockable_dict['is_voting_allowed'] = allowed
      blockable_dict['voting_prohibited_reason'] = reason

      self.respond_json({'blockable': blockable_dict, 'vote': vote})

  def get(self, blockable_id):
    """Gets user's vote for the given blockable."""
    logging.info('Vote handler get method called for %s.', blockable_id)

    ancestor_key = datastore_utils.ConcatenateKeys(
        ndb.Key(binary_models.Blockable, blockable_id), self.user.key)
    # pylint: disable=g-explicit-bool-comparison, singleton-comparison
    vote = vote_models.Vote.query(
        vote_models.Vote.in_effect == True, ancestor=ancestor_key).get()
    # pylint: enable=g-explicit-bool-comparison, singleton-comparison
    self.respond_json(vote)


# The Webapp2 routes defined for these handlers.
ROUTES = routes.PathPrefixRoute('/votes', [
    webapp2.Route(
        '/cast/<blockable_id>',
        handler=VoteCastHandler),
    webapp2.Route(
        '/query',
        handler=VoteQueryHandler),
    webapp2.Route(
        '/<vote_key>',
        handler=VoteHandler),
])
Ejemplo n.º 5
0
    routes.PathPrefixRoute('/api', [
        
        #
        # TODO - help home goes here - will there ever be time to make this?
        #
        
        #
        # cron endpoints
        #
        webapp2.Route(r'/cron/do/ldc_watchdog_cull', handler=watchdog_handlers.LabDataContainerWatchdogCullHandler),
        webapp2.Route(r'/cron/do/task_watchdog_clean_tasks', handler=watchdog_handlers.TaskWatchdogCleanTasksHandler),
        
        #
        # other services
        #
        webapp2.Route(r'/test', handler=misc_handlers.TestHandler),
        
        webapp2.Route(r'/time', handler=misc_handlers.TimeHandler), # time on the server right now
        # to be enabled in some future version, experimental: webapp2.Route(r'/keygen', handler=appkey_handlers.AppKeyGeneratorHandler),
        # to be enabled in some future version, experimental: webapp2.Route(r'/keytest', handler=appkey_handlers.AppKeyTestHandler),

        #
        # workers/status
        #
        routes.PathPrefixRoute('/workers', [
            webapp2.Route(r'/all/status', handler=worker_handlers.Workers_all_status_handler),
            webapp2.Route(r'/<guid>/status', handler=worker_handlers.Workers_status_handler),
            webapp2.Route(r'/<guid>/sys_health', handler=worker_handlers.Workers_sys_health_handler),
            webapp2.Route(r'/<guid>/log', handler=worker_handlers.Workers_log_handler),
        ]),

        #
        # topic/task queue access
        #
        routes.RedirectRoute(r'/topics', handler=topic_task_handlers.TopicCollectionHandler, strict_slash=True, name='Topipcs'),
        routes.PathPrefixRoute('/topics', [
            
            routes.RedirectRoute(r'/<topic_name>', handler=topic_task_handlers.TopicHandler, strict_slash=True, name='Topic'),
            
            webapp2.Route(r'/<topic_name>/num_recent_tasks', handler=topic_task_handlers.TaskStatsReporterHandler_num_recent_tasks_created),
            webapp2.Route(r'/<topic_name>/num_creatable_tasks', handler=topic_task_handlers.TopicHandler_num_creatable_tasks),
            webapp2.Route(r'/<topic_name>/max_num_tasks', handler=topic_task_handlers.TopicHandler_max_num_tasks),
            routes.RedirectRoute(r'/<topic_name>/offers', handler=topic_task_handlers.AssignTaskHandler, strict_slash=True, name='Topic_offers'),
            routes.RedirectRoute(r'/<topic_name>/tasks', handler=topic_task_handlers.TaskCollectionHandler, strict_slash=True, name='Topic_tasks'),
            routes.RedirectRoute(r'/<topic_name>/rejected_tasks', handler=topic_task_handlers.RejectedTaskCollectionHandler, strict_slash=True, name='Topic_rejected_tasks'),
            routes.RedirectRoute(r'/<topic_name>/rejected_tasks/count', handler=topic_task_handlers.RejectedTaskCountHandler, strict_slash=True, name='Topic_rejected_tasks_count'),
            routes.RedirectRoute(r'/<topic_name>/waiting_tasks', handler=topic_task_handlers.WaitingTaskCollectionHandler, strict_slash=True, name='Topic_waiting_tasks'),
            routes.RedirectRoute(r'/<topic_name>/waiting_tasks/count', handler=topic_task_handlers.WaitingTaskCountHandler, strict_slash=True, name='Topic_waiting_tasks_count'),
            routes.RedirectRoute(r'/<topic_name>/working_tasks', handler=topic_task_handlers.WorkingTaskCollectionHandler, strict_slash=True, name='Topic_working_tasks'),
            routes.RedirectRoute(r'/<topic_name>/working_tasks/count', handler=topic_task_handlers.WorkingTaskCountHandler, strict_slash=True, name='Topic_working_tasks_count'),
            routes.RedirectRoute(r'/<topic_name>/successful_tasks', handler=topic_task_handlers.SuccessfulTaskCollectionHandler, strict_slash=True, name='Topic_successful_tasks'),
            routes.RedirectRoute(r'/<topic_name>/failed_tasks', handler=topic_task_handlers.FailedTaskCollectionHandler, strict_slash=True, name='Topic_failed_tasks'),
            
            routes.RedirectRoute(r'/<topic_name>/tasks/<task_id>', handler=topic_task_handlers.TaskHandler, strict_slash=True, name='Task'),
            
            # TODO - pick one of these two styles of URL
            webapp2.Route(r'/<topic_name>/tasks/<task_id>/do/accept', handler=topic_task_handlers.AcceptTaskHandler),
            webapp2.Route(r'/<topic_name>/tasks/<task_id>/do/decline', handler=topic_task_handlers.DeclineTaskHandler),
            webapp2.Route(r'/<topic_name>/tasks/<task_id>/do/delegate', handler=topic_task_handlers.DelegateTaskHandler),
            webapp2.Route(r'/<topic_name>/tasks/<task_id>/do/progress', handler=topic_task_handlers.ProgressTaskHandler),
            webapp2.Route(r'/<topic_name>/tasks/<task_id>/do/stop', handler=topic_task_handlers.StopTaskHandler),
            webapp2.Route(r'/<topic_name>/tasks/<task_id>/do/reject', handler=topic_task_handlers.TaskModerationRejectHandler),
        ]),
        
        
        #
        # aceess to binary data
        #
        routes.PathPrefixRoute('/<ldc0:(bin)>', [
            webapp2.Route(r'', handler=ldc_handlers.RootLDCCollectionHandler),
            webapp2.Route(r'/', handler=ldc_handlers.RootLDCCollectionHandler, name='LabDataContainer-L0'),
            
            webapp2.Route(r'/<ldc1>', handler=ldc_handlers.LDCHandler),
            webapp2.Route(r'/<ldc1>/', handler=ldc_handlers.LDCHandler, name='LabDataContainer-L1'),
            webapp2.Route(r'/<ldc1>/do/delete', handler=ldc_handlers.LDCDeleteHandler),
            webapp2.Route(r'/<ldc1>/do/finish_big_upload', handler=ldc_handlers.LDCContentBigUploadHandler, name='LabDataContainer-L1-finish_upload'),
            webapp2.Route(r'/<ldc1>/content', handler=ldc_handlers.LDCContentHandler),

        ]),
    ])])
Ejemplo n.º 6
0
    def get_json(self):
        logging.info('t3j')
        self.render_json({"json": True})


routes = [
    Route(r'/', handler='main.HomeHandler'),
    routes.PathPrefixRoute(
        r'/fc',
        [
            Route(r'/', handler='main.FortunesHandler'),
            Route(r'/-/add', handler='main.AddFortuneHandler'),
            Route(r'/-/upload', handler='main.UploadFortuneHandler'),
            Route(r'/-/upload_file', handler='main.UploadFileFortuneHandler'),
            Route(r'/-/upload/<uid>',
                  handler='main.UploadStatusFortuneHandler'),
            #Route(r'/-/feed', handler='main.FortuneFeedHandler'),
            #Route(r'/-/feed/<feedtype>', handler='main.FortuneFeedHandler'),
            Route(r'/<fc>/-/edit', handler='main.EditFortuneHandler'),
            Route(r'/<fc>/<slug>', handler='main.FortuneHandler'),
            Route(r'/<fc>', handler='main.FortuneHandler'),
        ]),
    routes.PathPrefixRoute(r'/tags', [
        Route(r'/', handler='main.TagsHandler'),
        Route(r'/-/add', handler='main.AddTagHandler'),
        Route(r'/<tag>', handler='main.TagHandler'),
    ]),
    routes.PathPrefixRoute(r'/labels', [
        Route(r'/', handler='main.LabelsHandler'),
        Route(r'/-/add', handler='main.AddLabelHandler'),
from controllers import meeting_requests
from controllers import users
from controllers import auth

# Task handlers
from tasks.emails import *
from tasks.requests import *

# Endpoints API
app = endpoints.api_server([base.lunchmates_api], restricted=False)

# Tasks App Engine API
TASK_ROUTES = [
    DomainRoute(
        config.subdomain,
        [  # Allowed domains
            routes.PathPrefixRoute(
                r'/tasks',
                [

                    # Emails
                    Route(r'/email', handler=EmailTaskHandler),

                    # Send users a request summary of their pending incoming requests
                    Route(r'/request-summary', handler=RequestSummaryHandler)
                ])
        ])
]

tasks = webapp2.WSGIApplication(TASK_ROUTES, debug=True)
Ejemplo n.º 8
0
    @base.RequireCapability(constants.PERMISSIONS.EDIT_ALERTS)
    def post(self, scope, platform):

        scope, platform = self._ValidateRouteParams(scope, platform)

        # Verify that the alert payload has the minimum requirements before going
        # any further.
        for request_arg in ('message', 'start_date', 'severity'):
            if not self.request.get(request_arg).strip():
                self.abort(httplib.BAD_REQUEST,
                           'Missing request argument: %s' % request_arg)

        alert_db.Alert.Insert(message=self.request.get('message'),
                              details=self.request.get('details'),
                              start_date=self._ParseRequestDate('start_date'),
                              end_date=self._ParseRequestDate('end_date'),
                              platform=platform,
                              scope=scope,
                              severity=self.request.get('severity'))

        # Expire the memcache key in case the newly-created Alert which should take
        # priority over a current one. We don't need to reset the key, the next
        # relevant GET request should take care of it automatically.
        memcache.delete(_CreateMemcacheKey(scope, platform))


# The Webapp2 routes defined for these handlers.
ROUTES = routes.PathPrefixRoute('/alerts', [
    webapp2.Route('/<scope>/<platform>', handler=AlertHandler),
])
Ejemplo n.º 9
0
  def get(self):
    taskqueue_utils.CappedDefer(
        Pull, _PULL_MAX_QUEUE_SIZE, queue=constants.TASK_QUEUE.BIT9_PULL)


class CountEventsToProcess(handler_utils.CronJobHandler):

  def get(self):
    events_to_process = _UnsyncedEvent.query().count()  # pylint: disable=protected-access
    logging.info('There are currently %d unprocessed events', events_to_process)
    monitoring.events_to_process.Set(events_to_process)


class ProcessEvents(handler_utils.CronJobHandler):

  def get(self):
    taskqueue_utils.CappedDefer(
        Dispatch, _DISPATCH_MAX_QUEUE_SIZE,
        queue=constants.TASK_QUEUE.BIT9_DISPATCH)


ROUTES = routes.PathPrefixRoute('/bit9', [
    webapp2.Route('/commit-pending-change-sets', handler=CommitAllChangeSets),
    webapp2.Route('/update-policies', handler=UpdateBit9Policies),
    webapp2.Route('/count-events-to-pull', handler=CountEventsToPull),
    webapp2.Route('/pull-events', handler=PullEvents),
    webapp2.Route('/count-events-to-process', handler=CountEventsToProcess),
    webapp2.Route('/process-events', handler=ProcessEvents),
])