Exemplo n.º 1
0
class GoMetricsWorkerConfig(BaseWorker.CONFIG_CLASS, GoWorkerConfigMixin):
    """At the start of each `metrics_interval` the :class:`GoMetricsWorker`
       collects a list of all active conversations and distributes them
       into `metrics_interval / metrics_granularity` buckets.

       Immediately afterwards and then after each `metrics_granulatiry`
       interval, the metrics worker sends a `collect_metrics` command to each
       of the conversations in the current bucket until all buckets have been
       processed.

       Once all buckets have been processed, active conversations are
       collected again and the cycle repeats.
       """

    metrics_interval = ConfigInt(
        "How often (in seconds) the worker should send `collect_metrics` "
        "commands for each conversation. Must be an integer multiple of "
        "`metrics_granularity`.",
        default=300,
        static=True)

    metrics_granularity = ConfigInt(
        "How often (in seconds) the worker should process a bucket of "
        "conversations.",
        default=5,
        static=True)

    def post_validate(self):
        if (self.metrics_interval % self.metrics_granularity != 0):
            raise ConfigError("Metrics interval must be an integer multiple"
                              " of metrics granularity.")
Exemplo n.º 2
0
class TruteqTransportConfig(Transport.CONFIG_CLASS):
    username = ConfigText(
        'Username of the TruTeq account to connect to.', static=True)
    password = ConfigText(
        'Password for the TruTeq account.', static=True)
    twisted_endpoint = ConfigClientEndpoint(
        'The endpoint to connect to.',
        default='tcp:host=sms.truteq.com:port=50008', static=True,
        fallbacks=[ClientEndpointFallback()])
    link_check_period = ConfigInt(
        'Number of seconds between link checks sent to the server.',
        default=60, static=True)
    ussd_session_lifetime = ConfigInt(
        'Maximum number of seconds to retain USSD session information.',
        default=300, static=True)
    debug = ConfigBool(
        'Print verbose log output.', default=False, static=True)
    redis_manager = ConfigDict(
        'How to connect to Redis.', default={}, static=True)

    # TODO: Deprecate these fields when confmodel#5 is done.
    host = ConfigText(
        "*DEPRECATED* 'host' and 'port' fields may be used in place of the"
        " 'twisted_endpoint' field.", static=True)
    port = ConfigInt(
        "*DEPRECATED* 'host' and 'port' fields may be used in place of the"
        " 'twisted_endpoint' field.", static=True)
Exemplo n.º 3
0
class MessageForwardingConfig(ApplicationConfig):
    '''Config for MessageForwardingWorker application worker'''

    mo_message_url = ConfigText(
        "The URL to send HTTP POST requests to for MO messages",
        default=None,
        static=True)

    message_queue = ConfigText("The AMQP queue to forward messages on",
                               default=None,
                               static=True)

    redis_manager = ConfigDict("Redis config.", required=True, static=True)

    inbound_ttl = ConfigInt(
        "Maximum time (in seconds) allowed to reply to messages",
        required=True,
        static=True)

    outbound_ttl = ConfigInt(
        "Maximum time (in seconds) allowed for events to arrive for messages",
        required=True,
        static=True)

    metric_window = ConfigFloat(
        "Size of the buckets to use (in seconds) for metrics",
        required=True,
        static=True)
Exemplo n.º 4
0
class VumiBridgeTransportConfig(Transport.CONFIG_CLASS):
    account_key = ConfigText('The account key to connect with.',
                             static=True,
                             required=True)
    conversation_key = ConfigText('The conversation key to use.',
                                  static=True,
                                  required=True)
    access_token = ConfigText('The access token for the conversation key.',
                              static=True,
                              required=True)
    base_url = ConfigText('The base URL for the API',
                          static=True,
                          default='https://go.vumi.org/api/v1/go/http_api/')
    message_life_time = ConfigInt('How long to keep message_ids around for.',
                                  static=True,
                                  default=48 * 60 * 60)  # default is 48 hours.
    redis_manager = ConfigDict("Redis client configuration.",
                               default={},
                               static=True)
    max_reconnect_delay = ConfigInt(
        'Maximum number of seconds between connection attempts',
        default=3600,
        static=True)
    max_retries = ConfigInt(
        'Maximum number of consecutive unsuccessful connection attempts '
        'after which no further connection attempts will be made. If this is '
        'not explicitly set, no maximum is applied',
        static=True)
    initial_delay = ConfigFloat('Initial delay for first reconnection attempt',
                                default=0.1,
                                static=True)
    factor = ConfigFloat(
        'A multiplicitive factor by which the delay grows',
        # (math.e)
        default=2.7182818284590451,
        static=True)
    jitter = ConfigFloat(
        'Percentage of randomness to introduce into the delay length'
        'to prevent stampeding.',
        # molar Planck constant times c, joule meter/mole
        default=0.11962656472,
        static=True)
    web_port = ConfigInt(
        "The port to listen for requests on, defaults to `0`.",
        default=0,
        static=True)
    web_path = ConfigText("The path to listen for inbound requests on.",
                          required=True,
                          static=True)
    health_path = ConfigText(
        "The path to listen for downstream health checks on"
        " (useful with HAProxy)",
        default='health',
        static=True)
Exemplo n.º 5
0
class RapidSMSRelayConfig(ApplicationWorker.CONFIG_CLASS):
    """RapidSMS relay configuration."""

    web_path = ConfigText(
        "Path to listen for outbound messages from RapidSMS on.", static=True)
    web_port = ConfigInt(
        "Port to listen for outbound messages from RapidSMS on.", static=True)
    redis_manager = ConfigDict(
        "Redis manager configuration (only required if"
        " `allow_replies` is true)",
        default={},
        static=True)
    allow_replies = ConfigBool(
        "Whether to support replies via the `in_reply_to` argument"
        " from RapidSMS.",
        default=True,
        static=True)

    vumi_username = ConfigText(
        "Username required when calling `web_path` (default: no"
        " authentication)",
        default=None)
    vumi_password = ConfigText("Password required when calling `web_path`",
                               default=None)
    vumi_auth_method = ConfigText(
        "Authentication method required when calling `web_path`."
        "The 'basic' method is currently the only available method",
        default='basic')
    vumi_reply_timeout = ConfigInt(
        "Number of seconds to keep original messages in redis so that"
        " replies may be sent via `in_reply_to`.",
        default=10 * 60)
    allowed_endpoints = ConfigList('List of allowed endpoints to send from.',
                                   required=True,
                                   default=("default", ))

    rapidsms_url = ConfigUrl("URL of the rapidsms http backend.")
    rapidsms_username = ConfigText(
        "Username to use for the `rapidsms_url` (default: no authentication)",
        default=None)
    rapidsms_password = ConfigText("Password to use for the `rapidsms_url`",
                                   default=None)
    rapidsms_auth_method = ConfigText(
        "Authentication method to use with `rapidsms_url`."
        " The 'basic' method is currently the only available method.",
        default='basic')
    rapidsms_http_method = ConfigText(
        "HTTP request method to use for the `rapidsms_url`", default='POST')
Exemplo n.º 6
0
class MxitTransportConfig(HttpRpcTransport.CONFIG_CLASS):

    client_id = ConfigText('The OAuth2 ClientID assigned to this transport.',
                           required=True,
                           static=True)
    client_secret = ConfigText(
        'The OAuth2 ClientSecret assigned to this transport.',
        required=True,
        static=True)
    timeout = ConfigInt('Timeout for outbound Mxit HTTP API calls.',
                        required=False,
                        default=30,
                        static=True)
    redis_manager = ConfigDict('How to connect to Redis',
                               required=True,
                               static=True)
    api_send_url = ConfigText('The URL for the Mxit message sending API.',
                              required=False,
                              default="https://api.mxit.com/message/send/",
                              static=True)
    api_auth_url = ConfigText('The URL for the Mxit authentication API.',
                              required=False,
                              default='https://auth.mxit.com',
                              static=True)
    api_auth_scopes = ConfigList('The list of scopes to request access to.',
                                 required=False,
                                 static=True,
                                 default=['message/send'])
Exemplo n.º 7
0
class NetcoreTransportConfig(Transport.CONFIG_CLASS):

    twisted_endpoint = ConfigServerEndpoint(
        'The endpoint to listen on.',
        required=True,
        static=True,
        fallbacks=[ServerEndpointFallback()])
    web_path = ConfigText("The path to serve this resource on.",
                          default='/api/v1/netcore/',
                          static=True)
    health_path = ConfigText("The path to serve the health resource on.",
                             default='/health/',
                             static=True)
    reject_none = ConfigBool(
        "Reject messages where the content parameter equals 'None'",
        required=False,
        default=True,
        static=True)

    # TODO: Deprecate these fields when confmodel#5 is done.
    host = ConfigText(
        "*DEPRECATED* 'host' and 'port' fields may be used in place of the"
        " 'twisted_endpoint' field.",
        static=True)
    port = ConfigInt(
        "*DEPRECATED* 'host' and 'port' fields may be used in place of the"
        " 'twisted_endpoint' field.",
        static=True)
Exemplo n.º 8
0
Arquivo: mica.py Projeto: lynnUg/vumi
class SubmitShortMessageProcessorConfig(
        default.SubmitShortMessageProcessorConfig):

    max_session_length = ConfigInt(
        'Maximum length a USSD sessions data is to be kept for in seconds.',
        default=60 * 3,
        static=True)
Exemplo n.º 9
0
    class CONFIG_CLASS(BaseWorker.CONFIG_CLASS):
        worker_name = ConfigText(
            'Name of the this message store resource worker',
            required=True,
            static=True)
        twisted_endpoint = ConfigServerEndpoint(
            'Twisted endpoint to listen on.',
            required=True,
            static=True,
            fallbacks=[ServerEndpointFallback()])
        web_path = ConfigText('The path to serve this resource on.',
                              required=True,
                              static=True)
        health_path = ConfigText('The path to serve the health resource on.',
                                 default='/health/',
                                 static=True)
        riak_manager = ConfigDict('Riak client configuration.',
                                  default={},
                                  static=True)
        redis_manager = ConfigDict('Redis client configuration.',
                                   default={},
                                   static=True)

        # TODO: Deprecate these fields when confmodel#5 is done.
        host = ConfigText(
            "*DEPRECATED* 'host' and 'port' fields may be used in place of"
            " the 'twisted_endpoint' field.",
            static=True)
        port = ConfigInt(
            "*DEPRECATED* 'host' and 'port' fields may be used in place of"
            " the 'twisted_endpoint' field.",
            static=True)
Exemplo n.º 10
0
class TelnetServerConfig(Transport.CONFIG_CLASS):
    """
    Telnet transport configuration.
    """
    twisted_endpoint = ConfigServerEndpoint(
        "The endpoint the Telnet server will listen on.",
        fallbacks=[ServerEndpointFallback('telnet_host', 'telnet_port')],
        required=True,
        static=True)
    to_addr = ConfigText(
        "The to_addr to use for inbound messages. The default is to use"
        " the host:port of the telnet server.",
        default=None,
        static=True)
    transport_type = ConfigText(
        "The transport_type to use for inbound messages.",
        default='telnet',
        static=True)

    # TODO: Deprecate these fields when confmodel#5 is done.
    telnet_host = ConfigText(
        "*DEPRECATED* 'telnet_host' and 'telnet_port' fields may be used in"
        "place of the 'twisted_endpoint' field.",
        static=True)
    telnet_port = ConfigInt(
        "*DEPRECATED* 'telnet_host' and 'telnet_port' fields may be used in"
        " place of the 'twisted_endpoint' field.",
        static=True)
Exemplo n.º 11
0
class SequentialSendConfig(GoApplicationWorker.CONFIG_CLASS):
    poll_interval = ConfigInt(
        "Interval between polling watched conversations for scheduled events.",
        default=60,
        static=True)

    schedule = ConfigDict("Scheduler config.")
    messages = ConfigList("List of messages to send in sequence")
Exemplo n.º 12
0
class MessageForwardingConfig(ApplicationConfig):
    '''Config for MessageForwardingWorker application worker'''

    mo_message_url = ConfigUrl(
        "The URL to send HTTP POST requests to for MO messages",
        default=None,
        static=True)

    mo_message_url_auth_token = ConfigText(
        "Authorization Token to use for the mo_message_url",
        default=None,
        static=True)

    mo_message_url_timeout = ConfigInt(
        "Maximum time (in seconds) a mo_message_url is allowed to take "
        "to process a message",
        default=10,
        static=True)

    event_url_timeout = ConfigInt(
        "Maximum time (in seconds) an event_url is allowed to take "
        "to process an event",
        default=10,
        static=True)

    message_queue = ConfigText("The AMQP queue to forward messages on",
                               default=None,
                               static=True)

    redis_manager = ConfigDict("Redis config.", required=True, static=True)

    inbound_ttl = ConfigInt(
        "Maximum time (in seconds) allowed to reply to messages",
        required=True,
        static=True)

    outbound_ttl = ConfigInt(
        "Maximum time (in seconds) allowed for events to arrive for messages",
        required=True,
        static=True)

    metric_window = ConfigFloat(
        "Size of the buckets to use (in seconds) for metrics",
        required=True,
        static=True)
Exemplo n.º 13
0
 class CONFIG_CLASS(BaseWorker.CONFIG_CLASS):
     deadline = ConfigInt(
         "Check-in deadline for participating workers",
         required=True, static=True)
     redis_manager = ConfigDict(
         "Redis client configuration.",
         required=True, static=True)
     monitored_systems = ConfigDict(
         "Tree of systems and workers.",
         required=True, static=True)
Exemplo n.º 14
0
class SubmitShortMessageProcessorConfig(Config):
    submit_sm_encoding = ConfigText(
        'How to encode the SMS before putting on the wire',
        static=True,
        default='utf-8')
    submit_sm_data_coding = ConfigInt(
        'What data_coding value to tell the SMSC we\'re using when putting'
        'an SMS on the wire',
        static=True,
        default=0)
    send_long_messages = ConfigBool(
        "If `True`, messages longer than 254 characters will be sent in the "
        "`message_payload` optional field instead of the `short_message` "
        "field. Default is `False`, simply because that maintains previous "
        "behaviour.",
        default=False,
        static=True)
    send_multipart_sar = ConfigBool(
        "If `True`, messages longer than 140 bytes will be sent as a series "
        "of smaller messages with the sar_* parameters set. Default is "
        "`False`.",
        default=False,
        static=True)
    send_multipart_udh = ConfigBool(
        "If `True`, messages longer than 140 bytes will be sent as a series "
        "of smaller messages with the user data headers. Default is `False`.",
        default=False,
        static=True)
    multipart_sar_reference_rollover = ConfigInt(
        "The value at which the reference number of a multi part SMS will "
        "roll over. eg. a value of 2 will result in a series 0, 1, 0, 1 ...",
        default=0x10000,
        static=True)

    def post_validate(self):
        long_message_params = ('send_long_messages', 'send_multipart_sar',
                               'send_multipart_udh')
        set_params = [p for p in long_message_params if getattr(self, p)]
        if len(set_params) > 1:
            params = ', '.join(set_params)
            self.raise_config_error(
                "The following parameters are mutually exclusive: %s" % params)
Exemplo n.º 15
0
class TrueAfricanUssdTransportConfig(Transport.CONFIG_CLASS):
    """TrueAfrican USSD transport configuration."""

    port = ConfigInt("Bind to this port", required=True, static=True)
    interface = ConfigText("Bind to this interface", default='', static=True)
    redis_manager = ConfigDict("Parameters to connect to Redis with",
                               default={},
                               static=True)
    session_timeout = ConfigInt(
        "Number of seconds before USSD session information stored in"
        " Redis expires.",
        default=600,
        static=True)
    request_timeout = ConfigInt(
        "How long should we wait for the remote side generating the response"
        " for this synchronous operation to come back. Any connection that has"
        " waited longer than `request_timeout` seconds will manually be"
        " closed.",
        default=(4 * 60),
        static=True)
Exemplo n.º 16
0
class BaseConfig(Config):
    """Base config definition for workers.

    You should subclass this and add worker-specific fields.
    """

    amqp_prefetch_count = ConfigInt(
        "The number of messages fetched concurrently from each AMQP queue"
        " by each worker instance.",
        default=20,
        static=True)
Exemplo n.º 17
0
class DmarkUssdTransportConfig(HttpRpcTransport.CONFIG_CLASS):
    """Config for Dmark USSD transport."""

    ussd_session_timeout = ConfigInt(
        "Number of seconds before USSD session information stored in Redis"
        " expires.",
        default=600,
        static=True)

    redis_manager = ConfigDict("Redis client configuration.",
                               default={},
                               static=True)
Exemplo n.º 18
0
class MtnNigeriaUssdTransportConfig(Transport.CONFIG_CLASS):
    """MTN Nigeria USSD transport configuration."""

    server_hostname = ConfigText(
        "Hostname of the server the transport's client should connect to.",
        required=True,
        static=True)
    server_port = ConfigInt("Port that the server is listening on.",
                            required=True,
                            static=True)
    username = ConfigText("The username for this transport.",
                          required=True,
                          static=True)
    password = ConfigText("The password for this transport.",
                          required=True,
                          static=True)
    application_id = ConfigText(
        "An application ID required by MTN Nigeria for client authentication.",
        required=True,
        static=True)
    enquire_link_interval = ConfigInt(
        "The interval (in seconds) between enquire links sent to the server "
        "to check whether the connection is alive and well.",
        default=30,
        static=True)
    timeout_period = ConfigInt(
        "How long (in seconds) after sending an enquire link request the "
        "client should wait for a response before timing out. NOTE: The "
        "timeout period should not be longer than the enquire link interval",
        default=30,
        static=True)
    user_termination_response = ConfigText(
        "Response given back to the user if the user terminated the session.",
        default='Session Ended',
        static=True)
    redis_manager = ConfigDict("Parameters to connect to Redis with",
                               default={},
                               static=True)
    session_timeout_period = ConfigInt(
        "Max length (in seconds) of a USSD session", default=600, static=True)
Exemplo n.º 19
0
class SandboxConfig(ApplicationWorker.CONFIG_CLASS):

    sandbox = ConfigDict(
        "Dictionary of resources to provide to the sandbox."
        " Keys are the names of resources (as seen inside the sandbox)."
        " Values are dictionaries which must contain a `cls` key that"
        " gives the full name of the class that provides the resource."
        " Other keys are additional configuration for that resource.",
        default={},
        static=True)

    executable = ConfigText(
        "Full path to the executable to run in the sandbox.")
    args = ConfigList(
        "List of arguments to pass to the executable (not including"
        " the path of the executable itself).",
        default=[])
    path = ConfigText("Current working directory to run the executable in.")
    env = ConfigDict("Custom environment variables for the sandboxed process.",
                     default={})
    timeout = ConfigInt(
        "Length of time the subprocess is given to process a message.",
        default=60)
    recv_limit = ConfigInt(
        "Maximum number of bytes that will be read from a sandboxed"
        " process' stdout and stderr combined.",
        default=1024 * 1024)
    rlimits = ConfigDict(
        "Dictionary of resource limits to be applied to sandboxed"
        " processes. Defaults are fairly restricted. Keys maybe"
        " names or values of the RLIMIT constants in"
        " Python `resource` module. Values should be appropriate integers.",
        default={})
    logging_resource = ConfigText(
        "Name of the logging resource to use to report errors detected"
        " in sandboxed code (e.g. lines written to stderr, unexpected"
        " process termination). Set to null to disable and report"
        " these directly using Twisted logging instead.",
        default=None)
    sandbox_id = ConfigText("This is set based on individual messages.")
Exemplo n.º 20
0
class DeliverShortMessageProcessorConfig(
        default.DeliverShortMessageProcessorConfig):

    max_session_length = ConfigInt(
        'Maximum length a USSD sessions data is to be kept for in seconds.',
        default=60 * 3,
        static=True)

    ussd_code_pdu_field = ConfigText(
        'PDU field to read the message `to_addr` (USSD code) from. Possible'
        ' options are "short_message" (the default) and "destination_addr".',
        default='short_message',
        static=True)
Exemplo n.º 21
0
class HTTPWorkerConfig(GoApplicationWorker.CONFIG_CLASS):
    """Configuration options for StreamingHTTPWorker."""

    web_path = ConfigText("The path the HTTP worker should expose the API on.",
                          required=True,
                          static=True)
    web_port = ConfigInt("The port the HTTP worker should open for the API.",
                         required=True,
                         static=True)
    health_path = ConfigText(
        "The path the resource should receive health checks on.",
        default='/health/',
        static=True)
    concurrency_limit = ConfigInt(
        "Maximum number of clients per account. A value less than "
        "zero disables the limit",
        default=10)
    timeout = ConfigInt(
        "How long to wait for a response from a server when posting "
        "messages or events",
        default=5,
        static=True)
Exemplo n.º 22
0
class AirtelUSSDTransportConfig(HttpRpcTransport.CONFIG_CLASS):
    airtel_username = ConfigText('The username for this transport',
                                 default=None,
                                 static=True)
    airtel_password = ConfigText('The password for this transport',
                                 default=None,
                                 static=True)
    airtel_charge = ConfigBool(
        'Whether or not to charge for the responses sent.',
        required=False,
        default=False,
        static=True)
    airtel_charge_amount = ConfigInt('How much to charge',
                                     default=0,
                                     required=False,
                                     static=True)
    redis_manager = ConfigDict('Parameters to connect to Redis with.',
                               default={},
                               required=False,
                               static=True)
    session_key_prefix = ConfigText(
        'The prefix to use for session key management. Specify this'
        'if you are using more than 1 worker in a load-balanced'
        'fashion.',
        default=None,
        static=True)
    ussd_session_timeout = ConfigInt('Max length of a USSD session',
                                     default=60 * 10,
                                     required=False,
                                     static=True)
    to_addr_pattern = ConfigText(
        'A regular expression that to_addr values in messages that start a'
        ' new USSD session must match. Initial messages with invalid'
        ' to_addr values are rejected.',
        default=None,
        required=False,
        static=True,
    )
Exemplo n.º 23
0
class ConversationApiWorkerConfig(BaseWorker.CONFIG_CLASS):
    worker_name = ConfigText(
        "Name of this tagpool API worker.", required=True, static=True)
    web_path = ConfigText(
        "The path to serve this resource on.", required=True, static=True)
    web_port = ConfigInt(
        "The port to server this resource on.", required=True, static=True)
    health_path = ConfigText(
        "The path to server the health resource on.", default='/health/',
        static=True)
    redis_manager = ConfigDict(
        "Redis client configuration.", default={}, static=True)
    riak_manager = ConfigDict(
        "Riak client configuration.", default={}, static=True)
Exemplo n.º 24
0
class MTNRwandaUSSDTransportConfig(Transport.CONFIG_CLASS):
    """
    MTN Rwanda USSD transport configuration.
    """
    twisted_endpoint = ConfigServerEndpoint(
        "The listening endpoint that the remote client will connect to.",
        required=True,
        static=True,
        fallbacks=[ServerEndpointFallback()])
    timeout = ConfigInt(
        "No. of seconds to wait before removing a request that hasn't "
        "received a response yet.",
        default=30,
        static=True)
    redis_manager = ConfigDict("Parameters to connect to redis with",
                               default={},
                               static=True)
    session_timeout_period = ConfigInt("Maximum length of a USSD session",
                                       default=600,
                                       static=True)
    web_path = ConfigText("The path to serve this resource on.",
                          required=True,
                          static=True)
    health_path = ConfigText("The path to serve the health resource on.",
                             default='/health/',
                             static=True)

    # TODO: Deprecate these fields when confmodel#5 is done.
    host = ConfigText(
        "*DEPRECATED* 'host' and 'port' fields may be used in place of the"
        " 'twisted_endpoint' field.",
        static=True)
    port = ConfigInt(
        "*DEPRECATED* 'host' and 'port' fields may be used in place of the"
        " 'twisted_endpoint' field.",
        static=True)
Exemplo n.º 25
0
class VumiBridgeServerTransportConfig(VumiBridgeClientTransportConfig):
    # Most of this copied wholesale from vumi.transports.httprpc.

    web_port = ConfigInt(
        "The port to listen for requests on, defaults to `0`.",
        default=0,
        static=True)
    message_path = ConfigText("The path to listen for message requests on.",
                              required=True,
                              static=True)
    event_path = ConfigText("The path to listen for event requests on.",
                            required=True,
                            static=True)
    health_path = ConfigText(
        "The path to listen for downstream health checks on"
        " (useful with HAProxy)",
        default='health',
        static=True)
Exemplo n.º 26
0
class ChannelStatusConfig(BaseConfig):
    '''Config for the ChannelStatusWorker'''
    redis_manager = ConfigDict(
        "Redis config.",
        required=True, static=True)

    channel_id = ConfigText(
        "The channel id which this worker is consuming statuses for",
        required=True, static=True)

    status_url = ConfigText(
        "Optional url to POST status events to",
        default=None, static=True)

    status_url_timeout = ConfigInt(
        "Maximum time (in seconds) a status_url is allowed to take "
        "to process a status update",
        default=10, static=True)
Exemplo n.º 27
0
class DmarkUssdTransportConfig(HttpRpcTransport.CONFIG_CLASS):
    """Config for Dmark USSD transport."""

    ussd_session_timeout = ConfigInt(
        "Number of seconds before USSD session information stored in Redis"
        " expires.",
        default=600,
        static=True)

    fix_to_addr = ConfigBool(
        "Whether or not to ensure that the to_addr is always starting with a "
        "* and ending with a #",
        default=False,
        static=True)

    redis_manager = ConfigDict("Redis client configuration.",
                               default={},
                               static=True)
Exemplo n.º 28
0
class ApplicationMultiplexerConfig(GoRouterWorker.CONFIG_CLASS):

    # Static configuration
    session_expiry = ConfigInt(
        "Maximum amount of time in seconds to keep session data around",
        default=300, static=True)

    # Dynamic, per-message configuration
    menu_title = ConfigDict(
        "Content for the menu title",
        default={'content': "Please select a choice."})
    entries = ConfigList(
        "A list of application endpoints and associated labels",
        default=[])
    invalid_input_message = ConfigText(
        "Prompt to display when warning about an invalid choice",
        default=("That is an incorrect choice. Please enter the number "
                 "of the menu item you wish to choose.\n\n 1) Try Again"))
    error_message = ConfigText(
        ("Prompt to display when a configuration change invalidates "
         "an active session."),
        default=("Oops! We experienced a temporary error. "
                 "Please try and dial the line again."))
Exemplo n.º 29
0
class ParlayXTransportConfig(Transport.CONFIG_CLASS):
    web_notification_path = ConfigText(
        'Path to listen for delivery and receipt notifications on',
        static=True)
    web_notification_port = ConfigInt(
        'Port to listen for delivery and receipt notifications on',
        default=0, static=True)
    notification_endpoint_uri = ConfigText(
        'URI of the ParlayX SmsNotificationService in Vumi', static=True)
    short_code = ConfigText(
        'Service activation number or short code to receive deliveries for',
        static=True)
    remote_send_uri = ConfigText(
        'URI of the remote ParlayX SendSmsService', static=True)
    remote_notification_uri = ConfigText(
        'URI of the remote ParlayX SmsNotificationService', static=True)
    start_notifications = ConfigBool(
        'Start (and stop) the ParlayX notification service?', static=True)
    service_provider_service_id = ConfigText(
        'Provisioned service provider service identifier', static=True)
    service_provider_id = ConfigText(
        'Provisioned service provider identifier/username', static=True)
    service_provider_password = ConfigText(
        'Provisioned service provider password', static=True)
Exemplo n.º 30
0
class WikipediaConfig(ApplicationWorker.CONFIG_CLASS):
    api_url = ConfigUrl(
        "URL for the MediaWiki API to query. This defaults to the English"
        " Wikipedia. Any recent enough MediaWiki installation should be fine,"
        " although certain assumptions are made about the structure of"
        " articles that may not hold outside of Wikipedia.",
        default='https://en.wikipedia.org/w/api.php')

    api_timeout = ConfigInt("API call timeout in seconds.", default=5)
    include_url_in_sms = ConfigBool(
        "Include url in the first SMS",
        default=False
    )
    mobi_url_host = ConfigText(
        "The full mobi host url that will be used instead of the fullurl",
        default=None
    )
    shortening_api_url = ConfigUrl(
        "URL for the Praekelt URL Shortening Service",
        default=None
    )

    search_backend = ConfigText(
        "The Wikimedia search backend to use.", default=None, required=False,
        static=True)

    accept_gzip = ConfigBool(
        "If `True`, the HTTP client will request gzipped responses. This is"
        " generally beneficial, although it requires Twisted 11.1 or later.",
        default=False)

    user_agent = ConfigText(
        "Value of the `User-Agent` header on API requests.",
        default=('vumi-wikipedia/1.0 (https://github.com/praekelt/vumi-'
                 'wikipedia; [email protected])'))

    max_session_length = ConfigInt(
        "Lifetime of query session in seconds. This includes the lifetime of"
        " the content kept for further SMS deliveries.", default=600)

    max_ussd_content_length = ConfigInt(
        "Maximum character length of ASCII USSD content.", default=160)

    max_ussd_unicode_length = ConfigInt(
        "Maximum character length of unicode USSD content.", default=70)

    max_sms_content_length = ConfigInt(
        "Maximum character length of ASCII SMS content.", default=160)

    max_sms_unicode_length = ConfigInt(
        "Maximum character length of unicode SMS content.", default=70)

    sentence_break_threshold = ConfigInt(
        "If a sentence break is found within this many characters of the end"
        " of the truncated message, truncate at the sentence break instead of"
        " a word break.", default=10)

    transliterate_unicode = ConfigBool(
        "Set this to `True` to transliterate any non-ASCII chars. Requires"
        " unidecode lib.", default=False)

    minimize_text = ConfigBool(
        "Set this to `True` to attempt to shorten text by removing unnecessary"
        " chars.", default=False)

    send_sms_content = ConfigBool(
        "Set this to `False` to suppress the sending of content via SMS.",
        default=True)

    send_more_sms_content = ConfigBool(
        "Set this to `False` to ignore requests for more content via SMS.",
        default=True)

    metrics_prefix = ConfigText(
        "Prefix for metrics names. If unset, no metrics will be collected.",
        static=True)

    content_cache_time = ConfigInt(
        "Lifetime of cached article content in seconds. If unset, no caching"
        " will be done.", static=True, default=0)

    redis_manager = ConfigDict(
        "Redis connection configuration.", static=True, default={})

    msg_prompt = ConfigText(
        'Initial prompt shown to the users',
        default=u'What would you like to search Wikipedia for?')

    msg_no_results = ConfigText(
        'No results found message, with one string parameter',
        default=u'Sorry, no Wikipedia results for %s')

    msg_error = ConfigText(
        'Generic internal error message',
        default=u'Sorry, there was an error processing your request.'
        ' Please try again later.')

    msg_invalid_section = ConfigText(
        'User picked incorrect section',
        default=u'Sorry, invalid selection. Please restart and try again')

    msg_more_content_suffix = ConfigText(
        "Suffix for SMS content that can be continued. An empty string"
        " should be specified if there is no incoming SMS connection.",
        default=' (reply for more)')

    msg_no_more_content_suffix = ConfigText(
        "Suffix for SMS content that is complete. An empty string should be "
        " specified if there is no incoming SMS connection.",
        default=' (end of section)')

    msg_ussd_suffix = ConfigText(
        'Message to add at the end of the truncated USSD result',
        default=u'\n(Full content sent by SMS.)')

    secret_key = ConfigText(
        'Secret key to use when hashing the user-ids before logging.',
        static=True)

    hash_algorithm = ConfigText(
        'hashlib algorithm to use for hashing the user-ids', static=True,
        default='sha256')

    user_hash_char_limit = ConfigInt(
        'Limit the user-hash to how many characters. '
        'Defaults to -1 (leave as is)',
        static=True, default=-1)