def show_about(): try: content_provider = ContentProvider(app.config["PATH_CONTENT_FOLDER"]) about_content = content_provider.load_about() except ContentNotFoundException: about_content = "Content not found!" pass return render_template("about.html", content=about_content)
def show_about(): try: content_provider = ContentProvider(app.config["PATH_CONTENT_FOLDER"]) about_content = content_provider.load_about() except ContentNotFoundException: about_content = "Content not found!" pass return render_template('about.html', content=about_content)
def _CreateContentProvider(self, name, config): supports_templates = config.get('supportsTemplates', False) supports_zip = config.get('supportsZip', False) if 'chromium' in config: chromium_config = config['chromium'] if 'dir' not in chromium_config: logging.error('%s: "chromium" must have a "dir" property' % name) return None file_system = ChrootFileSystem(self._host_file_system, chromium_config['dir']) elif 'github' in config: github_config = config['github'] if 'owner' not in github_config or 'repo' not in github_config: logging.error( '%s: "github" must provide an "owner" and "repo"' % name) return None file_system = self._github_file_system_provider.Create( github_config['owner'], github_config['repo']) if 'dir' in github_config: file_system = ChrootFileSystem(file_system, github_config['dir']) else: logging.error('%s: content provider type "%s" not supported' % (name, type_)) return None return ContentProvider(name, self._compiled_fs_factory, file_system, supports_templates=supports_templates, supports_zip=supports_zip)
def _CreateContentProvider(self, name, config): default_extensions = config.get('defaultExtensions', ()) supports_templates = config.get('supportsTemplates', False) supports_zip = config.get('supportsZip', False) if 'chromium' in config: chromium_config = config['chromium'] if 'dir' not in chromium_config: logging.error('%s: "chromium" must have a "dir" property' % name) return None file_system = ChrootFileSystem(self._host_file_system, chromium_config['dir']) elif 'gitiles' in config: gitiles_config = config['gitiles'] if 'dir' not in gitiles_config: logging.error('%s: "gitiles" must have a "dir" property' % name) return None file_system = ChrootFileSystem(GitilesFileSystem.Create(), gitiles_config['dir']) elif 'gcs' in config: gcs_config = config['gcs'] if 'bucket' not in gcs_config: logging.error('%s: "gcs" must have a "bucket" property' % name) return None bucket = gcs_config['bucket'] if not bucket.startswith('gs://'): logging.error('%s: bucket %s should start with gs://' % (name, bucket)) return None bucket = bucket[len('gs://'):] file_system = self._gcs_file_system_provider.Create(bucket) if 'dir' in gcs_config: file_system = ChrootFileSystem(file_system, gcs_config['dir']) elif 'github' in config: github_config = config['github'] if 'owner' not in github_config or 'repo' not in github_config: logging.error( '%s: "github" must provide an "owner" and "repo"' % name) return None file_system = self._github_file_system_provider.Create( github_config['owner'], github_config['repo']) if 'dir' in github_config: file_system = ChrootFileSystem(file_system, github_config['dir']) else: logging.error('%s: content provider type not supported' % name) return None return ContentProvider(name, self._compiled_fs_factory, file_system, self._object_store_creator, default_extensions=default_extensions, supports_templates=supports_templates, supports_zip=supports_zip)
def _CreateContentProvider(self, supports_zip=False): test_file_system = TestFileSystem(_TEST_DATA) return ContentProvider( 'foo', CompiledFileSystem.Factory(ObjectStoreCreator.ForTest()), test_file_system, # TODO(kalman): Test supports_templates=False. supports_templates=True, supports_zip=supports_zip)
def _CreateContentProvider(self, supports_zip=False): object_store_creator = ObjectStoreCreator.ForTest() return ContentProvider( 'foo', CompiledFileSystem.Factory(object_store_creator), self._test_file_system, object_store_creator, default_extensions=('.html', '.md'), # TODO(kalman): Test supports_templates=False. supports_templates=True, supports_zip=supports_zip)
def _CreateContentProvider(self, name, config): default_extensions = config.get('defaultExtensions', ()) supports_templates = config.get('supportsTemplates', False) supports_zip = config.get('supportsZip', False) if 'chromium' in config: chromium_config = config['chromium'] if 'dir' not in chromium_config: logging.error('%s: "chromium" must have a "dir" property' % name) return None file_system = ChrootFileSystem(self._host_file_system, chromium_config['dir']) # TODO(rockot): Remove this in a future patch. It should not be needed once # the new content_providers.json is committed. elif 'gitiles' in config: chromium_config = config['gitiles'] if 'dir' not in chromium_config: logging.error('%s: "chromium" must have a "dir" property' % name) return None file_system = ChrootFileSystem(self._host_file_system, chromium_config['dir']) elif 'gcs' in config: gcs_config = config['gcs'] if 'bucket' not in gcs_config: logging.error('%s: "gcs" must have a "bucket" property' % name) return None bucket = gcs_config['bucket'] if not bucket.startswith('gs://'): logging.error('%s: bucket %s should start with gs://' % (name, bucket)) return None bucket = bucket[len('gs://'):] file_system = self._gcs_file_system_provider.Create(bucket) if 'dir' in gcs_config: file_system = ChrootFileSystem(file_system, gcs_config['dir']) else: logging.error('%s: content provider type not supported' % name) return None return ContentProvider(name, self._compiled_fs_factory, file_system, self._object_store_creator, default_extensions=default_extensions, supports_templates=supports_templates, supports_zip=supports_zip)
width = 1920 height = 1080 if options.resolution: try: tmpArr = options.resolution.split("x") width = int(tmpArr[0]) height = int(tmpArr[1]) except Exception as e: LOG.warning( "Exception while parsing resolution: %s.\nUsing full hd as default." % e) width = 1920 height = 1080 provider = ContentProvider(provider=az) provider.connect() info = az.getFilmInfo(amazonUrlOrAsin) mpdUrl = info["mpdUrl"] LOG.info("") LOG.info("Printing some useful stuff:") LOG.info("Title: %s" % info["title"]) LOG.info("MPD url: %s" % mpdUrl) LOG.info("Video Quality: %s" % info['videoQuality']) LOG.info("") if options.printResolutions: mpd_ = az.getMpdDataAndExtractInfos(mpdUrl) printResolutions(mpd_)
item["name"] = key item["size"] = counter[key] children.append(item) my_json["name"] = "News" my_json["children"] = children with open(filename, 'w') as outfile: json.dump(my_json, outfile) if __name__ == "__main__": now = int(time.time()) start = long(1000 * (now - (DAYS*86400))) end = long(1000 * now) # print datetime.datetime.fromtimestamp(d/1000).strftime("%Y-%m-%d %H:%M:%S") fetcher = ContentProvider() # get updated feed subscription categories try: subscriptions = fetcher.fetch_feeds() if "errorMessage" in subscriptions and "token expired" in subscriptions["errorMessage"]: fetcher.refresh_token() subscriptions = fetcher.fetch_feeds() categories = fetcher.fetch_categories() categoriesdb = db.categories # for category in categories: # category_id = categoriesdb.update(key, category, {upsert:true}) # category_id = categoriesdb.insert_one(category).inserted_id # key = {'key':'va`lue'} # data = {'key2':'value2', 'key3':'value3'}; # coll.update(key, data, {upsert:true});
def __init__(self, name): logger.info("Created mode " + name) self.repeat_pattern = RepeatPattern() self.name = name self.priority = 10000 self.provider = ContentProvider()
from article import Article from content_provider import ContentProvider from flask import Flask, render_template, request, url_for, redirect import time import base64 # create app instances app = Flask(__name__) # privedes fake news content content_provider = ContentProvider() # url parameter keys to look for header_key_string = "aGVhZGVy" image_url_key_string = "aW1hZ2VfdXJs" @app.route("/") def index(): page = render_template("index.html") return page @app.route("/random_article") def random_article(): generated_article = generate_article() content = generated_article.get_content_dict()