コード例 #1
0
ファイル: context.py プロジェクト: rubenrua/Galicaster
    def test_get_scheduler_and_occlient_none(self):
        conf = context.get_conf()

        conf.set('ingest', 'active', 'False')
        self.assertEqual(context.get_occlient(), None)
        self.assertEqual(context.get_scheduler(), None)

        context.delete('occlient')
        context.delete('scheduler')
        conf.set('ingest', 'active', 'True')
        self.assertEqual(type(context.get_occlient()), galicaster.opencast.client.OCHTTPClient)
        self.assertEqual(type(context.get_scheduler()), galicaster.scheduler.scheduler.Scheduler)
コード例 #2
0
ファイル: context.py プロジェクト: sinhote/Galicaster
    def test_get_scheduler_and_occlient_none(self):
        conf = context.get_conf()
        conf.set('ingest', 'active', 'False')

        self.assertEqual(context.get_occlient(), None)
        self.assertTrue(context.get_scheduler() != None)

        context.delete('occlient')
        context.delete('scheduler')
        conf.set('ingest', 'active', 'True')
        self.assertEqual(type(context.get_occlient()),
                         galicaster.opencast.client.OCHTTPClient)
        self.assertEqual(type(context.get_scheduler()),
                         galicaster.scheduler.scheduler.Scheduler)
コード例 #3
0
ファイル: series.py プロジェクト: rubenrua/Galicaster
def get_series():
    repo = context.get_repository() 
    occlient = context.get_occlient()

    # Import the 'series' section as a dictionary
    series_conf = context.get_conf().get_section('series')

    # Init 'queries' dictionary
    queries = {'startPage': 0, 'count': RESULTS_PER_PAGE}

    # Filter out keys that do not refer to a certain series property
    # Also, substitute any placeholder(s) used to filter the series
    # TODO Currently the only placeholder is {user}
    for key in series_conf.keys():
        if key not in DISALLOWED_QUERIES:
            try:
                queries[key] = series_conf[key].format(**MAPPINGS)
            except KeyError:
                # If the placeholder does not exist, log the issue but ignore it
                # TODO Log the exception
                pass
            
    try:
        series_list = []
        check_default = True
        while True:
            series_json = json.loads(occlient.getseries(**queries))
            for catalog in series_json['catalogs']:
                try:
                    series_list.append(parse_json_series(catalog))
                except KeyError:
                    # Ignore ill-formated series
                    pass
            if len(series_list) >= int(series_json['totalCount']):
                # Check the default series is present, otherwise query for it
                if 'default' in series_conf and check_default and series_conf['default'] not in dict(series_list):
                    check_default = False
                    queries = { "seriesId": series_conf['default'] }
                else:
                    break
            else:
                queries['startPage'] += 1

        repo.save_attach('series.json', json.dumps(series_list))

    except (ValueError, IOError, RuntimeError, AttributeError) as e:
        #TODO Log the exception
        try:
            series_list = json.load(repo.get_attach('series.json'))
        except (ValueError, IOError) as sub_e:
            #TODO Log the exception
            series_list = []

    return series_list
コード例 #4
0
ファイル: pushpic.py プロジェクト: rubenrua/Galicaster
def push_pic(sender=None):
    conf = context.get_conf()
    occlient = context.get_occlient()

    endpoint = "/dashboard/rest/agents/{hostname}/snapshot.png".format(hostname=conf.get_hostname())
    postfield = [ ("snapshot", get_screenshot() ) ]
    
    try:
        aux = occlient._OCHTTPClient__call('POST', endpoint, {}, {}, postfield, False, None, False)
    except IOError as e:
        # This endpoint return 204, not 200.
        aux = None
コード例 #5
0
def push_pic(sender=None):
    conf = context.get_conf()
    occlient = context.get_occlient()

    endpoint = "/dashboard/rest/agents/{hostname}/snapshot.png".format(
        hostname=conf.get_hostname())
    postfield = [("snapshot", get_screenshot())]

    try:
        occlient._OCHTTPClient__call('POST', endpoint, {}, {}, postfield,
                                     False, None, False)
    except IOError:
        # This endpoint return 204, not 200.
        pass
コード例 #6
0
ファイル: context.py プロジェクト: rubenrua/Galicaster
    def test_get_occlient_with_config(self):
        # Context init in other test
        if context.has('occlient'):
            context.delete('occlient') 

        host = "http://servertest.www.es"
        conf = context.get_conf()
        conf.set('ingest', 'active', 'True')
        original_host = conf.get('ingest', 'host')
        conf.set('ingest', 'host', host)
        client = context.get_occlient()
        self.assertNotEqual(original_host, client.server)
        self.assertEqual(host, client.server)

        context.delete('occlient') # Context init in other test
        hostname = 'foobar'
        conf.hostname = hostname
        client = context.get_occlient()
        self.assertEqual(hostname, client.hostname)

        context.delete('occlient') # Context init in other test
        conf.set('basic', 'admin', 'False')
        conf.remove_option('ingest', 'hostname')
        conf.hostname = conf.get_hostname()
        client = context.get_occlient()
        self.assertEqual('GC-' + socket.gethostname(), client.hostname)

        context.delete('occlient') # Context init in other test
        conf.set('basic', 'admin', 'True')
        conf.remove_option('ingest', 'hostname')
        conf.hostname = conf.get_hostname()
        client = context.get_occlient()
        self.assertEqual('GCMobile-' + socket.gethostname(), client.hostname)

        context.delete('conf') # To other test
        context.delete('occlient') # To other test
コード例 #7
0
ファイル: context.py プロジェクト: sinhote/Galicaster
    def test_get_occlient_with_config(self):
        # Context init in other test
        if context.has('occlient'):
            context.delete('occlient')

        host = "http://servertest.www.es"
        conf = context.get_conf()
        conf.set('ingest', 'active', 'True')
        original_host = conf.get('ingest', 'host')
        conf.set('ingest', 'host', host)
        client = context.get_occlient()
        self.assertNotEqual(original_host, client.server)
        self.assertEqual(host, client.server)

        context.delete('occlient')  # Context init in other test
        conf.remove_option('ingest', 'hostname')
        conf.set('ingest', 'hostname', 'foobar')
        client = context.get_occlient()
        self.assertEqual('foobar', client.hostname)

        context.delete('occlient')  # Context init in other test
        conf.set('basic', 'admin', 'False')
        conf.remove_option('ingest', 'hostname')
        conf.hostname = conf.get_hostname()
        client = context.get_occlient()
        self.assertEqual('GC-' + socket.gethostname(), client.hostname)

        context.delete('occlient')  # Context init in other test
        conf.set('basic', 'admin', 'True')
        conf.remove_option('ingest', 'hostname')
        conf.hostname = conf.get_hostname()
        client = context.get_occlient()
        self.assertEqual('GCMobile-' + socket.gethostname(), client.hostname)

        context.delete('conf')  # To other test
        context.delete('occlient')  # To other test
コード例 #8
0
def init():
    global recorder, dispatcher, logger, config, repo, oc_client, METADATA, ACL

    config = context.get_conf().get_section(CONFIG_SECTION) or {}
    dispatcher = context.get_dispatcher()
    repo = context.get_repository()
    logger = context.get_logger()
    recorder = context.get_recorder()
    oc_client = context.get_occlient()

    with open(get_ui_path("series_metadata_template.json"),
              "r") as metadataFile:
        METADATA = Template(metadataFile.read())

    with open(get_ui_path("acl_template.json"), "r") as aclFile:
        ACL = Template(aclFile.read())

    try:
        dispatcher.connect("init", init_user_ui)

    except Exception as e:
        logger.error(e)
    logger.info("Set user loaded.")
コード例 #9
0
ファイル: retryingest.py プロジェクト: FihlaTV/Galicaster
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import time

from galicaster.core import context
from galicaster.mediapackage import mediapackage

logger = context.get_logger()
conf = context.get_conf()
occlient = context.get_occlient()
repo = context.get_repository()

check_published = conf.get_boolean('retryingest', 'check_published')
check_after = conf.get_int('retryingest', 'check_after') or 300
check_nightly = conf.get_boolean('retryingest', 'nightly')
last_checked = time.time()


def init():
    logger.debug('check_published set to {}'.format(check_published))
    logger.debug('check_after set to {}'.format(str(check_after)))
    logger.debug('check_nightly set to {}'.format(check_nightly))

    try:
        dispatcher = context.get_dispatcher()
コード例 #10
0
ファイル: retryingest.py プロジェクト: rubenrua/Galicaster
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import time

from galicaster.core import context
from galicaster.mediapackage import mediapackage

logger = context.get_logger()
conf = context.get_conf()
occlient = context.get_occlient()
repo = context.get_repository()

check_published = conf.get_boolean('retryingest', 'check_published')
check_after = conf.get_int('retryingest', 'check_after') or 300
check_nightly = conf.get_boolean('retryingest', 'nightly')
last_checked = time.time()

logger.debug('check_published set to {}'.format(check_published))
logger.debug('check_after set to {}'.format(str(check_after)))
logger.debug('check_nightly set to {}'.format(check_nightly))


def init():        
    try:
        dispatcher = context.get_dispatcher()