コード例 #1
0
ファイル: tracking.py プロジェクト: errikos/indico-plugins
def track_download_request(download_url, download_title):
    """Track a download in Piwik"""
    from indico_piwik.plugin import PiwikPlugin

    if not download_url:
        raise ValueError("download_url can't be empty")
    if not download_title:
        raise ValueError("download_title can't be empty")

    request = PiwikRequest(
        server_url=PiwikPlugin.settings.get('server_api_url'),
        site_id=PiwikPlugin.settings.get('site_id_events'),
        api_token=PiwikPlugin.settings.get('server_token'),
        query_script=PiwikPlugin.track_script)

    action_url = quote(download_url)
    dt = datetime.now()
    request.call(idsite=request.site_id,
                 rec=1,
                 action_name=quote(download_title),
                 url=action_url,
                 download=action_url,
                 h=dt.hour,
                 m=dt.minute,
                 s=dt.second)
コード例 #2
0
 def __init__(self, query_script):
     from indico_piwik.plugin import PiwikPlugin
     self.request = PiwikRequest(
         server_url=PiwikPlugin.settings.get('server_api_url'),
         site_id=PiwikPlugin.settings.get('site_id_events'),
         api_token=PiwikPlugin.settings.get('server_token'),
         query_script=query_script)
コード例 #3
0
class PiwikQueryBase(object):
    """Base Piwik query"""
    def __init__(self, query_script):
        from indico_piwik.plugin import PiwikPlugin
        self.request = PiwikRequest(
            server_url=PiwikPlugin.settings.get('server_api_url'),
            site_id=PiwikPlugin.settings.get('site_id_events'),
            api_token=PiwikPlugin.settings.get('server_token'),
            query_script=query_script)

    def call(self, **query_params):
        return self.request.call(**query_params)
コード例 #4
0
ファイル: base.py プロジェクト: florv/indico-plugins
class PiwikQueryBase(object):
    """Base Piwik query"""

    def __init__(self, query_script):
        from indico_piwik.plugin import PiwikPlugin
        self.request = PiwikRequest(server_url=PiwikPlugin.settings.get('server_api_url'),
                                    site_id=PiwikPlugin.settings.get('site_id_events'),
                                    api_token=PiwikPlugin.settings.get('server_token'),
                                    query_script=query_script)

    def call(self, **query_params):
        return self.request.call(**query_params)
コード例 #5
0
ファイル: tracking.py プロジェクト: indico/indico-plugins
def track_download_request(download_url, download_title):
    """Track a download in Piwik"""
    from indico_piwik.plugin import PiwikPlugin

    if not download_url:
        raise ValueError("download_url can't be empty")
    if not download_title:
        raise ValueError("download_title can't be empty")

    request = PiwikRequest(server_url=PiwikPlugin.settings.get('server_api_url'),
                           site_id=PiwikPlugin.settings.get('site_id_events'),
                           api_token=PiwikPlugin.settings.get('server_token'),
                           query_script=PiwikPlugin.track_script)

    action_url = quote(download_url)
    dt = datetime.now()
    request.call(idsite=request.site_id,
                 rec=1,
                 action_name=quote(download_title.encode('utf-8')),
                 url=action_url,
                 download=action_url,
                 h=dt.hour, m=dt.minute, s=dt.second)
コード例 #6
0
ファイル: base.py プロジェクト: florv/indico-plugins
 def __init__(self, query_script):
     from indico_piwik.plugin import PiwikPlugin
     self.request = PiwikRequest(server_url=PiwikPlugin.settings.get('server_api_url'),
                                 site_id=PiwikPlugin.settings.get('site_id_events'),
                                 api_token=PiwikPlugin.settings.get('server_token'),
                                 query_script=query_script)