def __init__(self, job_file_path):
     self._job_file_path = job_file_path
     self.log = configure_logger(self.job_name)
     self._arg_parser = ArgumentParser()
     self.args = None
     self.start_ts = datetime.now()
     self.end_ts = None
     self.success = False
Exemple #2
0
"""Define the commands to run Selene batch jobs and the execution schedule.

This module is run as a daemon on the Selene batch host.  It defines the
commands needed to run each job using the subprocess module.  The jobs are
scheduled using the "schedule" library.
"""
import os
import subprocess
import time
from datetime import date, timedelta

import schedule

from selene.util.log import configure_logger

_log = configure_logger('selene_job_scheduler')


class JobRunner(object):
    """Build the command to run a batch job and run it via subprocess."""
    def __init__(self, script_name: str):
        self.script_name = script_name
        self.job_args: str = None
        self.job_date: date = None

    def run_job(self):
        if self.job_date is not None:
            self._add_date_to_args()
        command = self._build_command()
        self._execute_command(command)
Exemple #3
0
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
"""Define the API that will support Mycroft single sign on (SSO)."""
import os

from flask import Flask, request

from selene.api import get_base_config, selene_api, SeleneResponse
from selene.api.endpoints import AccountEndpoint, AgreementsEndpoint
from selene.util.log import configure_logger
from .endpoints import (AuthenticateInternalEndpoint, GithubTokenEndpoint,
                        LogoutEndpoint, PasswordChangeEndpoint,
                        PasswordResetEndpoint, ValidateEmailEndpoint,
                        ValidateFederatedEndpoint, ValidateTokenEndpoint)

_log = configure_logger('sso_api')

# Define the Flask application
sso = Flask(__name__)
sso.config.from_object(get_base_config())
sso.config.update(RESET_SECRET=os.environ['JWT_RESET_SECRET'])
sso.config.update(GITHUB_CLIENT_ID=os.environ['GITHUB_CLIENT_ID'])
sso.config.update(GITHUB_CLIENT_SECRET=os.environ['GITHUB_CLIENT_SECRET'])
sso.response_class = SeleneResponse
sso.register_blueprint(selene_api)

# Define the endpoints
sso.add_url_rule('/api/account',
                 view_func=AccountEndpoint.as_view('account_endpoint'),
                 methods=['POST'])
Exemple #4
0
"""Entry point for the API that supports the Mycroft Marketplace."""
from flask import Flask

from selene.api import get_base_config, selene_api, SeleneResponse
from selene.api.endpoints import AccountEndpoint, AgreementsEndpoint
from selene.util.cache import SeleneCache
from selene.util.log import configure_logger
from .endpoints import (PreferencesEndpoint, CityEndpoint, CountryEndpoint,
                        AccountDefaultsEndpoint, DeviceEndpoint,
                        DeviceCountEndpoint, GeographyEndpoint,
                        MembershipEndpoint, RegionEndpoint,
                        PairingCodeEndpoint, SkillsEndpoint,
                        SkillOauthEndpoint, SkillSettingsEndpoint,
                        TimezoneEndpoint, VoiceEndpoint, WakeWordEndpoint)

_log = configure_logger('account_api')

# Define the Flask application
acct = Flask(__name__)
acct.config.from_object(get_base_config())
acct.response_class = SeleneResponse
acct.register_blueprint(selene_api)
acct.config['SELENE_CACHE'] = SeleneCache()

account_endpoint = AccountEndpoint.as_view('account_endpoint')
acct.add_url_rule('/api/account',
                  view_func=account_endpoint,
                  methods=['GET', 'POST', 'PATCH', 'DELETE'])

agreements_endpoint = AgreementsEndpoint.as_view('agreements_endpoint')
acct.add_url_rule('/api/agreement/<string:agreement_type>',
Exemple #5
0
from .endpoints.device_skill_settings import DeviceSkillSettingsEndpoint
from .endpoints.device_skill_settings import DeviceSkillSettingsEndpointV2
from .endpoints.device_subscription import DeviceSubscriptionEndpoint
from .endpoints.geolocation import GeolocationEndpoint
from .endpoints.google_stt import GoogleSTTEndpoint
from .endpoints.oauth_callback import OauthCallbackEndpoint
from .endpoints.open_weather_map import OpenWeatherMapEndpoint
from .endpoints.premium_voice import PremiumVoiceEndpoint
from .endpoints.stripe_webhook import StripeWebHookEndpoint
from .endpoints.wake_word_file import WakeWordFileUpload
from .endpoints.wolfram_alpha import WolframAlphaEndpoint
from .endpoints.wolfram_alpha_simple import WolframAlphaSimpleEndpoint
from .endpoints.wolfram_alpha_spoken import WolframAlphaSpokenEndpoint
from .endpoints.wolfram_alpha_v2 import WolframAlphaV2Endpoint

_log = configure_logger("public_api")

public = Flask(__name__)
public.config.from_object(get_base_config())
public.config["GOOGLE_STT_KEY"] = os.environ["GOOGLE_STT_KEY"]
public.config["SELENE_CACHE"] = SeleneCache()
public.response_class = SeleneResponse
public.register_blueprint(selene_api)
public.add_url_rule(
    "/v1/device/<string:device_id>/skill/<string:skill_gid>",
    view_func=DeviceSkillSettingsEndpoint.as_view("device_skill_delete_api"),
    methods=["DELETE"],
)
public.add_url_rule(
    "/v1/device/<string:device_id>/skill",
    view_func=DeviceSkillSettingsEndpoint.as_view("device_skill_api"),
Exemple #6
0
"""Entry point for the API that supports the Mycroft Marketplace."""
from flask import Flask

from selene.api import get_base_config, selene_api, SeleneResponse
from selene.api.endpoints import AccountEndpoint
from selene.util.cache import SeleneCache
from selene.util.log import configure_logger
from .endpoints import (
    AvailableSkillsEndpoint,
    SkillDetailEndpoint,
    SkillInstallEndpoint,
    SkillInstallStatusEndpoint
)

_log = configure_logger('market_api')

# Define the Flask application
market = Flask(__name__)
market.config.from_object(get_base_config())
market.response_class = SeleneResponse
market.register_blueprint(selene_api)
market.config['SELENE_CACHE'] = SeleneCache()

# Define the API and its endpoints.
account_endpoint = AccountEndpoint.as_view('account_endpoint')
market.add_url_rule(
    '/api/account',
    view_func=account_endpoint,
    methods=['GET']
)
Exemple #7
0
from .endpoints.device_setting import DeviceSettingEndpoint
from .endpoints.device_skill import SkillSettingsMetaEndpoint
from .endpoints.device_skill_manifest import DeviceSkillManifestEndpoint
from .endpoints.device_skill_settings import DeviceSkillSettingsEndpoint
from .endpoints.device_skill_settings import DeviceSkillSettingsEndpointV2
from .endpoints.device_subscription import DeviceSubscriptionEndpoint
from .endpoints.geolocation import GeolocationEndpoint
from .endpoints.google_stt import GoogleSTTEndpoint
from .endpoints.oauth_callback import OauthCallbackEndpoint
from .endpoints.open_weather_map import OpenWeatherMapEndpoint
from .endpoints.premium_voice import PremiumVoiceEndpoint
from .endpoints.stripe_webhook import StripeWebHookEndpoint
from .endpoints.wolfram_alpha import WolframAlphaEndpoint
from .endpoints.wolfram_alpha_spoken import WolframAlphaSpokenEndpoint

_log = configure_logger('public_api')

public = Flask(__name__)
public.config.from_object(get_base_config())
public.config['GOOGLE_STT_KEY'] = os.environ['GOOGLE_STT_KEY']
public.config['SELENE_CACHE'] = SeleneCache()
public.response_class = SeleneResponse
public.register_blueprint(selene_api)
public.add_url_rule(
    '/v1/device/<string:device_id>/skill/<string:skill_gid>',
    view_func=DeviceSkillSettingsEndpoint.as_view('device_skill_delete_api'),
    methods=['DELETE']
)
public.add_url_rule(
    '/v1/device/<string:device_id>/skill',
    view_func=DeviceSkillSettingsEndpoint.as_view('device_skill_api'),
Exemple #8
0
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
"""Entry point for the API that supports the Mycroft Marketplace."""
from flask import Flask

from selene.api import get_base_config, selene_api, SeleneResponse
from selene.util.log import configure_logger
from .endpoints import AudioFileEndpoint, DesignationEndpoint, TagEndpoint

_log = configure_logger("precise_api")

# Define the Flask application
precise = Flask(__name__)
precise.config.from_object(get_base_config())
precise.response_class = SeleneResponse
precise.register_blueprint(selene_api)

audio_file_endpoint = AudioFileEndpoint.as_view("audio_file_endpoint")
precise.add_url_rule("/api/audio/<string:file_name>",
                     view_func=audio_file_endpoint,
                     methods=["GET"])

designation_endpoint = DesignationEndpoint.as_view("designation_endpoint")
precise.add_url_rule("/api/designation",
                     view_func=designation_endpoint,
Exemple #9
0
    DeviceEndpoint,
    DeviceCountEndpoint,
    GeographyEndpoint,
    MembershipEndpoint,
    RegionEndpoint,
    PairingCodeEndpoint,
    SkillsEndpoint,
    SkillOauthEndpoint,
    SkillSettingsEndpoint,
    SoftwareUpdateEndpoint,
    TimezoneEndpoint,
    VoiceEndpoint,
    WakeWordEndpoint,
)

_log = configure_logger("account_api")

# Define the Flask application
acct = Flask(__name__)
acct.config.from_object(get_base_config())
acct.response_class = SeleneResponse
acct.register_blueprint(selene_api)
acct.config["SELENE_CACHE"] = SeleneCache()

account_endpoint = AccountEndpoint.as_view("account_endpoint")
acct.add_url_rule("/api/account",
                  view_func=account_endpoint,
                  methods=["GET", "PATCH", "DELETE"])

agreements_endpoint = AgreementsEndpoint.as_view("agreements_endpoint")
acct.add_url_rule(