當前位置: 首頁>>代碼示例>>Python>>正文


Python models.App類代碼示例

本文整理匯總了Python中rogerthat.models.App的典型用法代碼示例。如果您正苦於以下問題:Python App類的具體用法?Python App怎麽用?Python App使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了App類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get

    def get(self):
        url_app_id = self.request.get('id')
        if url_app_id:
            app = get_app_by_id(url_app_id)
            if app:
                self.write_app_details(app)
                return

        url_new_app = self.request.get('new_app')
        if url_new_app:
            self.write_app_details(None)
            return

        rogerthat_app = get_app_by_id(App.APP_ID_ROGERTHAT)
        if rogerthat_app is None:
            rogerthat_app = App(key=App.create_key(App.APP_ID_ROGERTHAT))
            rogerthat_app.name = "Rogerthat"
            rogerthat_app.type = App.APP_TYPE_ROGERTHAT
            rogerthat_app.creation_time = now()
            rogerthat_app.visible = False
            rogerthat_app.put()

        template = JINJA_ENVIRONMENT.get_template('apps.html')
        context = self.get_request_params()
        context['apps'] = sorted(get_visible_apps(), key=lambda app: (app.is_default, app.name))
        self.response.out.write(template.render(context))
開發者ID:gitter-badger,項目名稱:rogerthat-backend,代碼行數:26,代碼來源:apps.py

示例2: run

    def run(self, bucket_name, key, current_date):
        # type: (str, str, long) -> GeneratorType
        shards = max(2, int(App.all(keys_only=True).count() / 100))  # A maximum of 100 apps will be logged per shard
        logging.info('Starting ServiceStatsPipeline with %d shards', shards)
        params = {
            'mapper_spec': 'rogerthat.bizz.job.service_stats.mapper',
            'mapper_params': {
                'bucket_name': bucket_name,
                'entity_kind': 'rogerthat.models.ServiceIdentity',
                'filters': []
            },
            'combiner_spec': 'rogerthat.bizz.job.service_stats.combiner',
            'reducer_spec': 'rogerthat.bizz.job.service_stats.reducer',
            'reducer_params': {
                'output_writer': {
                    'bucket_name': bucket_name
                }
            },
            'input_reader_spec': 'mapreduce.input_readers.DatastoreInputReader',
            'output_writer_spec': 'mapreduce.output_writers.GoogleCloudStorageConsistentOutputWriter',
            'shards': shards
        }

        output = yield mapreduce_pipeline.MapreducePipeline(key, **params)

        process_output_pipeline = yield ProcessOutputPipeline(output, current_date)
        with pipeline.After(process_output_pipeline):
            yield CleanupGoogleCloudStorageFiles(output)
開發者ID:our-city-app,項目名稱:mobicage-backend,代碼行數:28,代碼來源:service_stats.py

示例3: trans

 def trans(create_app_to):
     app_key = App.create_key(create_app_to.app_id)
     if App.get(app_key):
         raise DuplicateAppIdException(create_app_to.app_id)
     app = App(
         key=app_key,
         type=data.type,
         name=create_app_to.name,
         is_default=False,
         android_app_id=u'com.mobicage.rogerthat.%s' % create_app_to.app_id.replace('-', '.'),
         dashboard_email_address=data.dashboard_email_address,
         creation_time=now(),
     )
     app_settings = AppSettings(key=AppSettings.create_key(app.app_id),
                                background_fetch_timestamps=[21600] if app.type == App.APP_TYPE_CITY_APP else [])
     db.put((app, app_settings))
     return app
開發者ID:rogerthat-platform,項目名稱:rogerthat-backend,代碼行數:17,代碼來源:app.py

示例4: setup_qr_templates

    def setup_qr_templates(self, app_id):
        app = App.get(App.create_key(app_id))
        app.qrtemplate_keys = list()

        description = u"DEFAULT"
        key_name = create_qr_template_key_name(app_id, description)
        store_template(None, DEFAULT_QR_CODE_OVERLAY, description, u"".join(("%X" % c).rjust(2, '0')
                                                                            for c in DEFAULT_QR_CODE_COLOR), key_name)
        app.qrtemplate_keys.append(key_name)

        description = u"HAND"
        key_name = create_qr_template_key_name(app_id, description)
        store_template(None, HAND_ONLY_QR_CODE_OVERLAY, description, u"".join(("%X" % c).rjust(2, '0')
                                                                              for c in DEFAULT_QR_CODE_COLOR), key_name)
        app.qrtemplate_keys.append(key_name)

        put_and_invalidate_cache(app)
開發者ID:rogerthat-platform,項目名稱:rogerthat-backend,代碼行數:17,代碼來源:mc_unittest.py

示例5: migrate

def migrate():
    for app in App.all():
        settings_key = AppSettings.create_key(app.app_id)
        new_settings = AppSettings(key=settings_key,
                                   background_fetch_timestamps=[21600] if app.type == App.APP_TYPE_CITY_APP else [])
        settings = AppSettings.get(settings_key) or new_settings
        settings.put()
        get_app_settings.invalidate_cache(app.app_id)  # @UndefinedVariable
開發者ID:our-city-app,項目名稱:mobicage-backend,代碼行數:8,代碼來源:app_settings.py

示例6: validate_delete_service

def validate_delete_service(service_user):
    # type: (users.User) -> None
    all_app_ids = set()
    for service_identity in get_service_identities(service_user):
        all_app_ids.update(service_identity.appIds)
    apps = get_apps_by_keys([App.create_key(app_id) for app_id in all_app_ids])
    for app in apps:
        if app.main_service == service_user.email():
            raise BusinessException('Cannot delete main service of app %s' % app.app_id)
開發者ID:our-city-app,項目名稱:mobicage-backend,代碼行數:9,代碼來源:delete_service.py

示例7: generate_all_stats

def generate_all_stats():
    apps = App.all().fetch(None)
    app_ids = [a.app_id for a in apps]
    d = datetime.now()
    date = datetime(year=d.year, month=d.month, day=d.day)
    results = [
        generate_created_app_stats(apps),
        generate_released_app_stats(apps),
        generate_users_per_app_stats(app_ids)
    ]
    for type_, result in results:
        log_offload.create_log(None, type_, result, None, timestamp=time.mktime(date.timetuple()))
開發者ID:rogerthat-platform,項目名稱:rogerthat-backend,代碼行數:12,代碼來源:statistics.py

示例8: get

 def get(self):
     expired_apps = [(app.app_id, time.ctime(app.apple_push_cert_valid_until))
                     for app in App.all() \
                         .filter('apple_push_cert_valid_until !=', None) \
                         .filter('apple_push_cert_valid_until <', now() + 60 * 86400) \
                         .order('apple_push_cert_valid_until')]
     if expired_apps:
         expired_apps_str = pprint.pformat(expired_apps)
         settings = get_server_settings()
         send_mail(settings.dashboardEmail,
                   settings.supportWorkers,
                   "There are APN certs that are about to expire",
                   "The following APN certs are about to expire:\n%s" % expired_apps_str)
         logging.error("The following APN certs are about to expire:\n%s" % expired_apps_str)
開發者ID:rogerthat-platform,項目名稱:rogerthat-backend,代碼行數:14,代碼來源:apn_expiration_check.py

示例9: get

    def get(self):
        data_dict, app_user = self.get_user_info()
        if not data_dict or not app_user:
            return

        azzert(data_dict['a'] == "unsubscribe deactivate")

        app, user_profile = db.get([App.create_key(get_app_id_from_app_user(app_user)),
                                    UserProfile.createKey(app_user)])

        if not user_profile:
            self.redirect("/")
            return

        mobiles = list(get_user_active_mobiles(app_user))
        if mobiles:
            mobile = mobiles[0]
            if mobile.type in Mobile.ANDROID_TYPES:
                page_type = "android"
            elif mobile.type in Mobile.IOS_TYPES:
                page_type = "ios"
            else:
                return self.return_error()
        else:
            mobile = None
            page_type = "web"

        page_type = self.request.get("page_type", page_type)
        language = self.request.get("language", user_profile.language)

        ActivationLog(timestamp=now(), email=app_user.email(), mobile=mobile,
                      description="Visit unsubscribe page %s %s" % (page_type, user_profile.language)).put()

        jinja_template = self.get_jinja_environment().get_template('unsubscribe_deactivate.html')

        params = {
            'name': data_dict['n'],
            'app_name': get_app_by_user(app_user).name,
            'hide_header': True,
            'data': self.request.get("data"),
            'app_email': app_user.email(),
            'email': get_human_user_from_app_user(app_user).email(),
            'action': data_dict['a'],
            'page_type': page_type,
            'language': language,
            'is_city_app': app.type == App.APP_TYPE_CITY_APP
        }

        self.response.out.write(jinja_template.render(params))
開發者ID:rogerthat-platform,項目名稱:rogerthat-backend,代碼行數:49,代碼來源:unsubscribe_reminder_service.py

示例10: trans

    def trans(old_default_app_key):
        new_default_app = get_app_by_id(app_id)
        if new_default_app.key() == old_default_app_key:
            return

        new_default_app.is_default = True

        if old_default_app_key:
            old_default_app = App.get(old_default_app_key)
            old_default_app.is_default = False
            put_and_invalidate_cache(new_default_app, old_default_app)
            on_trans_committed(logging.info, "Default app updated from %s (%s) to %s (%s)", old_default_app.app_id,
                               old_default_app.name, new_default_app.app_id, new_default_app.name)
        else:
            put_and_invalidate_cache(new_default_app)
開發者ID:gitter-badger,項目名稱:rogerthat-backend,代碼行數:15,代碼來源:apps.py

示例11: generate_app_stats_history

def generate_app_stats_history(log_type):
    if log_type == 'rogerthat.created_apps':
        stats_func = _generate_created_app_stats
    elif log_type == 'rogerthat.released_apps':
        stats_func = _generate_released_app_stats
    else:
        raise Exception('Invalid log type')
    d = datetime.utcfromtimestamp(1410963082)
    date = datetime(year=d.year, month=d.month, day=d.day)
    all_apps = App.all().fetch(None)
    now = datetime.now()
    while date < now:
        ts = time.mktime(date.timetuple())
        result = stats_func([app for app in all_apps if app.creation_time <= ts])
        log_offload.create_log(None, log_type, result, None, timestamp=ts)
        date = date + relativedelta(days=1)
開發者ID:rogerthat-platform,項目名稱:rogerthat-backend,代碼行數:16,代碼來源:statistics.py

示例12: delete_app

def delete_app(app_id):
    app = get_app(app_id)
    validate_can_delete_app(app)
    to_delete = [
        AppSettings.create_key(app_id),
        app.key()
    ]
    to_put = []
    for profile_key in UserProfile.all(keys_only=True).filter('app_id', app_id):
        delete_account(users.User(profile_key.parent().name()))
    for other_app in App.all():
        if app_id in other_app.orderable_app_ids:
            other_app.orderable_app_ids.remove(app_id)
            to_put.append(other_app)
    db.delete(to_delete)
    if to_put:
        put_and_invalidate_cache(to_put)
開發者ID:rogerthat-platform,項目名稱:rogerthat-backend,代碼行數:17,代碼來源:app.py

示例13: _send_export_email

def _send_export_email(result_path, human_user_email, app_id, data_export_email, download_url):
    logging.info(download_url)
    app_user = create_app_user_by_email(human_user_email, app_id)
    user_profile, app = db.get([get_profile_key(app_user), App.create_key(app_id)])

    subject = localize(user_profile.language, "user_data_download_ready_summary")
    variables = dict(name=user_profile.name,
                     link=download_url,
                     app=app)
    body = render("data_download_ready_email", [user_profile.language], variables)
    html = render("data_download_ready_email_html", [user_profile.language], variables)
    server_settings = get_server_settings()

    email_receivers = [data_export_email]
    if app.is_default:
        email_sender = server_settings.senderEmail
    else:
        email_sender = ("%s <%s>" % (app.name, app.dashboard_email_address))

    send_mail(email_sender, email_receivers, subject, body, html=html)
    deferred.defer(_cleanup_export, result_path, _countdown=4 * DAY, _queue=DATA_EXPORT_QUEUE)
開發者ID:rogerthat-platform,項目名稱:rogerthat-backend,代碼行數:21,代碼來源:export.py

示例14: get_app_by_id

def get_app_by_id(app_id):
    # type: (unicode) -> App
    return get_cached_model(App.create_key(app_id))
開發者ID:our-city-app,項目名稱:mobicage-backend,代碼行數:3,代碼來源:app.py

示例15: post

    def post(self):
        success = False
        app_id = self.request.POST.get("app_id", None)
        name = self.request.POST.get("name", None)
        app_type = self.request.POST.get("app_type", None)
        fb_app_id = self.request.POST.get("fb_app_id", None)
        ios_app_id = self.request.POST.get("ios_app_id", None)
        android_app_id = self.request.POST.get("android_app_id", None)
        dashboard_email_address = self.request.POST.get('dashboard_email_address', None)
        contact_email_address = self.request.POST.get("contact_email_address", None)
        user_regex = self.request.POST.get("user_regex", None)
        qr_templates_count = int(self.request.POST.get("qr_templates_count", 0))
        default_qr_template_index = int(self.request.POST.get("default_qr_template_index", 0))
        auto_connected_services_string = self.request.POST.get("auto_connected_services", "[]")
        logging.debug("auto_connected_services = %s", auto_connected_services_string)
        beacon_major_str = self.request.POST.get("beacon_major", 0)
        beacon_major = int(beacon_major_str) if beacon_major_str else 0
        demo = bool(self.request.POST.get("demo", ''))
        beta = bool(self.request.POST.get("beta", ''))
        mdp_client_id = self.request.POST.get('mdp_client_id', None)
        mdp_client_secret = self.request.POST.get('mdp_client_secret', None)
        orderable_apps = self.request.get_all('orderable_apps')
        auto_connected_services = parse_complex_value(AutoConnectedService,
                                                      json.loads(auto_connected_services_string),
                                                      True)
        admin_services = json.loads(self.request.POST.get('admin_services', '[]'))
        beacon_regions = json.loads(self.request.POST.get("beacon_regions", "[]"))

        try:
            app_type = None if not app_type else int(app_type)
        except Exception:
            app_type = None

        try:
            fb_app_id = None if not fb_app_id else int(fb_app_id)
        except Exception:
            fb_app_id = None

        if not app_id:
            result = "Failed to create new app (app_id was empty)!"
        elif [c for c in app_id if c not in '-abcdefghijklmnopqrstuvwxyz0123456789']:
            result = "App ids should only contain (-, lower case alphabet characters and numbers)"
        elif not name:
            result = "Failed to create new app (name was empty)!"
        elif app_type is None:
            result = "Failed to create new app (app_type was empty)!"
        elif not ios_app_id:
            result = "Failed to create new app (ios_app_id was empty)!"
        elif not android_app_id:
            result = "Failed to create new app (android_app_id was empty)!"
        elif not dashboard_email_address:
            result = "Failed to create new app (dashboard_email_address was empty)!"
        else:
            try:
                if user_regex:
                    validate_user_regex(user_regex)

                zip_stream = self.request.POST.get('core_branding').file
                zip_stream.seek(0)
                try:
                    zip_ = ZipFile(zip_stream)
                except BadZipfile, e:
                    raise BrandingValidationException(e.message)

                branding = store_branding_zip(None, zip_, u"Core branding of %s" % app_id)

                app = App(key=App.create_key(app_id))
                to_be_put = []
                app.qrtemplate_keys = []
                for i in xrange(qr_templates_count):
                    file_ = self.request.POST.get('qr_template_%s' % i)
                    description = self.request.POST.get("qr_template_description_%s" % i)
                    color = self.request.POST.get("qr_template_color_%s" % i)
                    file_ = file_.file.getvalue() if isinstance(file_, FieldStorage) else None
                    key_name = create_qr_template_key_name(app_id, description)
                    store_template(None, file_, description, color, key_name)
                    if default_qr_template_index == i:
                        app.qrtemplate_keys.insert(0, key_name)
                    else:
                        app.qrtemplate_keys.append(key_name)

                app.name = name
                app.type = app_type
                app.core_branding_hash = branding.hash
                app.facebook_app_id = fb_app_id
                app.ios_app_id = ios_app_id
                app.android_app_id = android_app_id
                app.dashboard_email_address = dashboard_email_address
                app.contact_email_address = contact_email_address
                app.user_regex = user_regex
                app.creation_time = now()
                app.is_default = get_default_app_key() is None
                app.demo = demo
                app.beta = beta
                app.mdp_client_id = mdp_client_id or None
                app.mdp_client_secret = mdp_client_secret or None

                app.auto_connected_services = AutoConnectedServices()
                for acs in auto_connected_services:
                    service_identity_user = add_slash_default(users.User(acs.service_identity_email))
#.........這裏部分代碼省略.........
開發者ID:gitter-badger,項目名稱:rogerthat-backend,代碼行數:101,代碼來源:apps.py


注:本文中的rogerthat.models.App類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。