Beispiel #1
0
    def fill_metainfo(self, label):
        self.set_device()
        if label:
            q = gdata.blogger.client.Query(categories=[label.encode('utf-8')],
                                           max_results=0)
        else:
            q = gdata.blogger.client.Query(max_results=0)
        feed = util.get_posts(q)
        if feed:
            self.view.blog_title = feed.title.text
            self.view.title = 'Blog Information'
            author = feed.author[0].name
            total_posts = int(feed.total_results.text)
            blog_id = util.get_settings().get('blog_id')

            content = []
            content.append(info.Item('Author', author))
            content.append(info.Item('Blog ID', blog_id))
            content.append(info.Item('Blog Title', feed.title.text))
            if label:
                self.view.title += (": search result for [%s]" % label)
                self.view.label = label
                content.append(info.Item('Total search results', total_posts))
            else:
                content.append(info.Item('Total posts', total_posts))

            self.view.content = content
        else:
            logging.error("Fail to get Atom feed")
Beispiel #2
0
    def fill_view_attrs(self, post_id):
        user_agent = self.request.headers['User-Agent']
        view = self.view.type
        self.view.device = device.get_device(user_agent, view)

        client = BloggerPostClient()
        settings = util.get_settings()
        entry = client.get_one_post(settings.get('blog_id'), post_id)
        if entry:
            self.view.title = entry.title.text
            self.view.permalink = entry.get_html_link().href

            labels = []
            for label in entry.category:
                labels.append(label.term)
            labels.sort()
            self.view.labels = labels
            util.save_labels(labels, self.request, self.response)

            self.view.published = util.get_datetime_from_iso8601(entry.published.text[:19])
            if entry.updated:
                self.view.isUpdated = True
                self.view.updated =  util.get_datetime_from_iso8601(entry.updated.text[:19])
            self.view.content = util.replace_permalinks(entry.content.text)
        else:
            logging.error("Fail to get Atom feed for the post, #%d" % post_id)
Beispiel #3
0
def generate(write_loc=None, logger=None):
    if logger is None:
        logger = util.setup_logging('console')
    settings = util.get_settings()
    if write_loc is None:
        write_loc = os.path.join(settings.generated_root, 'conserver.cf')

    logger.info("generate: started")
    try:
        logger.debug("generate: pulling data")
        db = None
        try:
            db = transactional.DBSession(transactional.DB_URI)
        except Exception, ex:
            raise
        results = transactional.get_console_hnodes(db)
        conserves = {}
        for result in results:
            console_props = {}
            console_props['id'] = result['id']
            console_props['fqdn'] = result['handle']
            props = transactional.get_console_props(db, result['id'])
            console_props['host'] = props['host']
            console_props['include'] = props['include']
            console_props['baud'] = props['baud']
            conserves[result['id']] = console_props

        hnodes_with_consoles = {}
        results = transactional.get_hnodes_with_consoles(db)
        for result in results:
            hnodes_with_consoles[result['handle']] = \
                    {'conserver': conserves[result['id']], 
                     'port': result['console_port']}
Beispiel #4
0
def get_connection():
    settings = get_settings()

    # Connect to the database
    connection = pymysql.connect(host=settings['db']['host'],
                                 user=settings['db']['user'],
                                 password=settings['db']['pass'],
                                 db=settings['db']['database'],
                                 charset='utf8mb4',
                                 cursorclass=pymysql.cursors.DictCursor)
    return connection
def initialize_workspace(ctx):
    ctx.obj['CURRENT_DIR'] = os.getcwd()
    ctx.obj['IS_TEST_PROJ'] = None
    ctx.obj['WORKSPACE_PATH'] = util.find_workspace_root()
    if not ctx.obj['WORKSPACE_PATH']:
        click.echo('Error: not in an EGA submission workspace!', err=True)
        ctx.abort()

    # read the settings
    ctx.obj['SETTINGS'] = util.get_settings(ctx.obj['WORKSPACE_PATH'])
    if not ctx.obj['SETTINGS']:
        click.echo('Error: unable to read config file, or config file invalid!', err=True)
        ctx.abort()

    # figure out the current dir type, e.g., study, sample or analysis
    ctx.obj['CURRENT_DIR_TYPE'] = util.get_current_dir_type(ctx)
    if not ctx.obj['CURRENT_DIR_TYPE']:
        click.echo('Error: the current working directory does not associate with any known EGA object type', err=True)
        ctx.abort()
Beispiel #6
0
    def __init__(self, title=None, default_width=1000, default_height=800, **kw):
        if not title:
            title = GLib.get_application_name()

        super().__init__(title=title, default_width=default_width, default_height=default_height, **kw)

        util.init_actions(self, [{ 'name': 'about', 'activate': self._about }])

        self.builder = Gtk.Builder()
        self.builder.add_from_resource('/org/madbob/Assetxplorer/main.ui')

        self.set_titlebar(self.builder.get_object('main-header'))
        self.new_button = self.builder.get_object('new-button')
        self.new_button.connect('clicked', self._on_new_folder)
        self.back_button = self.builder.get_object('back-button')
        self.back_button.connect('clicked', self._on_back)

        self.stack = self.builder.get_object('main-stack')
        self.add(self.stack)
        self.stack.show_all()

        self.viewer = self.builder.get_object('contents')

        self.folderslist = self.builder.get_object('list')
        self.folderslist.get_style_context().add_class("assetxplorer-folders")
        self.folderslist.connect('row-activated', self._view_folder)

        self.conf = util.get_settings('org.madbob.Assetxplorer')
        folders = self.conf.get_value('folders')
        if folders:
            self.stack.set_visible_child(self.folderslist)
            for f in folders:
                self._create_button(f)
        else:
            empty = self.builder.get_object('empty')
            self.stack.set_visible_child(empty)
Beispiel #7
0
#!/usr/local/bin/python3

from jira import JIRA
from util import get_settings, hours_between
from jira_utils import get_numbers_for_time_spend_for_status, getTimeSpentIn
import sys

settings = get_settings()
options = {'server': settings["jira"]["server"]}
jira = JIRA(options,
            basic_auth=(settings["jira"]["user"],
                        settings["jira"]["password"]))

issues = jira.search_issues("key = CLM-10571")

for issue in issues:
    print(getTimeSpentIn(jira, issue, "In Development"))

#print(get_numbers_for_time_spend_for_status(jira, issues, "In Development"), sep=", ")

#print(hours_between("2018-08-02T17:52:46.898+0000", "2018-07-31T17:03:35.621+0000"))
Beispiel #8
0
#!/usr/bin/env python3

import os
import sys
import adal
import json
from flask import Flask, render_template
import requests
import util
import logging

log = logging.getLogger()

util.get_settings()

log.debug("Env vars: \n" + str(os.environ))

app = Flask(__name__, static_url_path='/static')

# Make the WSGI interface available at the top level so wfastcgi can get it.
wsgi_app = app.wsgi_app

@app.route('/api/token')
def get_token():
    context = adal.AuthenticationContext(
        os.environ['PBI_AUTHORITY'],
        validate_authority=True,
        api_version=None)

    token_response = context.acquire_token_with_username_password(
        os.environ['PBI_RESOURCE'],