예제 #1
0
def setup_turbomail(config):
    from turbomail.control import interface
    
    cmap = {
        'smtp_server': 'mail.smtp.server',
        'smtp_username': '******',
        'smtp_password': '******',
        'smtp_use_tls': 'mail.smtp.tls'
    }
    
    boolkeys = (
        'mail.smtp.tls',
        'mail.tls',
        'mail.smtp.debug',
        'mail.debug'
    )
    
    for k, v in config.items():
        if k in cmap and cmap[k] not in config:
            config[cmap[k]] = v
    
    for k, v in config.items():
        if k.endswith('.on') or (k in boolkeys):
            config[k] = asbool(v)
    
    if config.get('mail.on'):
        interface.start(config)
예제 #2
0
파일: tm_pylons.py 프로젝트: mbbui/Jminee
def start_extension():
    # There is no guarantee that atexit calls shutdown but Pylons does not 
    # provide other mechanisms!
    atexit.register(shutdown_extension)
    
    # interface.start will exit immediately if TurboMail is not enabled.
    interface.start(FakeConfigObj(config))
예제 #3
0
 def init_mta(self, policy_class=IMTAPolicy):
     super(TestSMTPTransport, self).init_mta(policy_class)
     self.connection_string = '%s:%s' % (self.hostname, self.listen_port)
     config = self.config.copy()
     config.update({'mail.smtp.server': self.connection_string})
     # We must not assume that TurboMail is installed with egg-info
     interface.start(config, extra_classes=self.fake_setuptools)
 def test_provide_dict_with_additional_managers_and_transports_which_overrides_setuptools(self):
     config = self.config.copy()
     config.update({'mail.manager': 'immediate', 'mail.transport': 'foo',})
     interface.start(config, extra_classes=dict(immediate=self.manager, foo=self.transport))
     self.assertEqual(self.manager, interface.manager)
     self.assertEqual(self.transport, interface.transport)
     interface.send(self.message)
예제 #5
0
def send_mail(subject='',
              to=[],
              cc=[],
              bcc=[],
              template='',
              lang='zh',
              values={},
              ip=ip,
              ):
    interface.start(email_config)
    msg = Message(sender_address,
                  to,
                  subject,
                  cc=cc,
                  bcc=bcc,
                  plain=subject if template else 'Plain Text',
                  )

    if template:
        try:
            url_root = request.url_root
        except:
            url_root = 'http://{}'.format(ip)

        if 'http://localhost' in url_root:
            url_root = 'http://{}'.format(ip)

        msg.rich = render_template('notifications/{}'.format(template),
                                   lang=lang,
                                   url_root=url_root,
                                   **values
                                   )
        msg.send()
        interface.stop()
예제 #6
0
 def test_with_extension_utf8_encoding_uses_base64(self):
     self.config['mail.utf8qp.on'] =  False
     interface.start(self.config, extra_classes=self.fake_setuptools)
     
     self.message.encoding = 'utf-8'
     msg = email.message_from_string(str(self.message))
     self.assertEqual('text/plain; charset="utf-8"', msg['Content-Type'])
     self.assertEqual('base64', msg['Content-Transfer-Encoding'])
예제 #7
0
 def test_no_default_for_smtp_server(self):
     """Test that the user is forced to configure the SMTP server to use
     explicitely to minize the likelihood that mails are sent out although
     they shouldn't due to misconfigurations."""
     # We must not assume that TurboMail is installed with egg-info
     interface.start(self.config, extra_classes=self.fake_setuptools)
     
     self.assertRaises(MailConfigurationException, self.msg.send)
예제 #8
0
파일: beakerd.py 프로젝트: sibiaoluo/beaker
def reload_config():
    purge_handlers()

    if interface.running:
        interface.stop()

    load_config(opts.configfile)
    interface.start(config)
 def test_can_provide_classes_for_extensions_to_override_setuptools(self):
     config = self.config.copy()
     config.update({'mail.manager': 'immediate', 'mail.transport': 'foo',
                    'mail.fake_ext.on': True})
     dummy_extension = DummyExtension()
     interface.start(config, extra_classes=dict(immediate=self.manager, foo=self.transport,
                                                fake_ext=dummy_extension))
     self.assertEqual(True, dummy_extension.started)
예제 #10
0
 def test_utf8qp_extension_reconfigures_utf8_setting(self):
     self.config['mail.utf8qp.on'] =  True
     interface.start(self.config, extra_classes=self.fake_setuptools)
     
     self.message.encoding = 'utf-8'
     msg = email.message_from_string(str(self.message))
     self.assertEqual('text/plain; charset="utf-8"', msg['Content-Type'])
     self.assertEqual('quoted-printable', msg['Content-Transfer-Encoding'])
예제 #11
0
 def enable_turbomail(self):
     from warnings import warn
     warn('enable_turbomail() is deprecated. Prefer enable_marrow_mailer()')
     from turbomail.control import interface
     import atexit
     options = {key: self.settings[key] for key in self.settings \
         if key.startswith('mail.')}
     interface.start(options)
     atexit.register(interface.stop, options)
예제 #12
0
    def setUp(self):
        super(TestController, self).setUp()

        config = {
            'mail.on': True,
            'mail.manager': 'immediate',
            'mail.transport': 'debug'
        }
        interface.start(config)
예제 #13
0
 def test_message_enqueue(self):
     config = {'mail.on': True}
     fake_setuptools =  {'immediate': ImmediateManager,
                         'debug': DebugTransportFactory}
     interface.start(config, extra_classes=fake_setuptools)
     
     message = Message('*****@*****.**', '*****@*****.**', 'Test')
     message.plain = 'Hello world!'
     turbomail.enqueue(message)
예제 #14
0
 def test_can_send_pregenerated_messages_with_dict(self):
     config = {'mail.on': True}
     fake_setuptools =  {'immediate': ImmediateManager,
                         'debug': DebugTransportFactory}
     interface.start(config, extra_classes=fake_setuptools)
     
     msg_info = dict(sender='*****@*****.**', recipients='*****@*****.**',
                     message=rfc822_msg)
     turbomail.enqueue(msg_info)
예제 #15
0
 def setUp(self):
     super(TestController, self).setUp()
     
     config = {
         'mail.on': True,
         'mail.manager': 'immediate',
         'mail.transport': 'debug'
     }
     interface.start(config)
예제 #16
0
 def setUp(self):
     config = {'mail.on': True, 
               'mail.manager': 'immediate', 'mail.transport': 'debug',}
     # conciously using classes and instances for fake_setuptools so that
     # the test also checks that TurboMail will do the right thing.
     fake_setuptools =  {'immediate': ImmediateManager,
                         'debug': DebugTransportFactory()}
     interface.start(config, extra_classes=fake_setuptools)
     self.msg = Message('*****@*****.**', '*****@*****.**', 'Test', 
                        plain='Plain text body')
 def test_all_loaded_extensions_are_stopped(self):
     config = self.config.copy()
     config.update({'mail.manager': 'immediate', 'mail.transport': 'foo',
                    'mail.fake_ext.on': True})
     dummy_extension = DummyExtension()
     interface.start(config, extra_classes=dict(immediate=self.manager, foo=self.transport,
                                                fake_ext=dummy_extension))
     self.assertEqual(True, dummy_extension.started)
     
     interface.stop()
     self.assertEqual(False, dummy_extension.started)
예제 #18
0
    def send(self, mfrom, mto, subject, html_part):

        interface.start(self.turbomail_config)

        message = Message(mfrom, mto, subject=subject)
        #message.cc =('idea','*****@*****.**')
        message.encoding = 'gb2312'
        message.plain = "Mabotech"
        message.rich = html_part
        message.send()

        interface.stop()
예제 #19
0
파일: beakerd.py 프로젝트: clrkwllms/beaker
def schedule():
    global running
    global _outstanding_data_migrations

    _outstanding_data_migrations = [
        m for m in DataMigration.all() if not m.is_finished
    ]
    if _outstanding_data_migrations:
        log.debug('Incomplete data migrations will be run: %s',
                  ', '.join(m.name for m in _outstanding_data_migrations))

    interface.start(config)

    if config.get('carbon.address'):
        log.debug('starting metrics thread')
        metrics_thread = threading.Thread(target=metrics_loop, name='metrics')
        metrics_thread.daemon = True
        metrics_thread.start()

    beakerd_threads = set(["main_recipes"])

    log.debug("starting main recipes thread")
    main_recipes_thread = threading.Thread(target=main_recipes_loop,
                                           name="main_recipes")
    main_recipes_thread.daemon = True
    main_recipes_thread.start()

    try:
        while True:
            time.sleep(20)
            running_threads = set([t.name for t in threading.enumerate()])
            if not running_threads.issuperset(beakerd_threads):
                log.critical("a thread has died, shutting down")
                rc = 1
                running = False
                event.set()
                break
            event.set()
            event.clear()
    except (SystemExit, KeyboardInterrupt):
        log.info("shutting down")
        running = False
        event.set()
        rc = 0

    if _threadpool_executor:
        _threadpool_executor.shutdown()
    interface.stop()
    main_recipes_thread.join(10)

    sys.exit(rc)
예제 #20
0
def schedule():
    global running
    global _outstanding_data_migrations

    _outstanding_data_migrations = [m for m in DataMigration.all() if not m.is_finished]
    if _outstanding_data_migrations:
        log.debug('Incomplete data migrations will be run: %s',
                ', '.join(m.name for m in _outstanding_data_migrations))

    interface.start(config)

    if config.get('carbon.address'):
        log.debug('starting metrics thread')
        metrics_thread = threading.Thread(target=metrics_loop, name='metrics')
        metrics_thread.daemon = True
        metrics_thread.start()

    beakerd_threads = set(["main_recipes"])

    log.debug("starting main recipes thread")
    main_recipes_thread = threading.Thread(target=main_recipes_loop,
                                           name="main_recipes")
    main_recipes_thread.daemon = True
    main_recipes_thread.start()

    try:
        while True:
            time.sleep(20)
            running_threads = set([t.name for t in threading.enumerate()])
            if not running_threads.issuperset(beakerd_threads):
                log.critical("a thread has died, shutting down")
                rc = 1
                running = False
                event.set()
                break
            event.set()
            event.clear()
    except (SystemExit, KeyboardInterrupt):
       log.info("shutting down")
       running = False
       event.set()
       rc = 0

    if _threadpool_executor:
        _threadpool_executor.shutdown()
    interface.stop()
    main_recipes_thread.join(10)

    sys.exit(rc)
예제 #21
0
def send_mail(subject, body, author=None, **kwargs):
    interface.start(email_config)
    msg = Message(author or from_, parse_mail(kwargs.get('to', [])), subject)
    msg.cc = parse_mail(kwargs.get('cc', []))
    bcc = kwargs.get('bcc', [])
    if not bcc:
        if kwargs.get('debug', True):
            bcc = debug_list

    msg.bcc = parse_mail(bcc)
    msg.plain = subject
    msg.rich = body
    [msg.attach(attachment) for attachment in kwargs.get('attachments', [])]
    msg.send()
    interface.stop()
예제 #22
0
def main():
    current_date = None
    parser = get_parser()
    opts, args = parser.parse_args()
    threshold = opts.threshold
    reservation_type = opts.reservation_type.decode(sys.stdin.encoding or "utf8")
    testing = opts.testing
    configfile = opts.configfile
    load_config(configfile)
    log_to_stream(sys.stderr)
    interface.start(config)
    get_engine()
    if testing:
        print "Dry run only, nothing will be sent\n"
    identify_nags(threshold, reservation_type, testing)
예제 #23
0
파일: mail.py 프로젝트: AbletonAG/abl.robot
def configure(conf):
    """
    Configures the turbomail system.
    """
    default_conf = {
        "manager" :             "immediate",
        "transport" :           "smtp",
        "smtp.server" :         "localhost",
        "message.encoding" :    "utf-8",
        "utf8qp.on" :           True,
        }
    default_conf.update(conf)
    for key in default_conf.keys():
        default_conf["mail." + key] = default_conf[key]
        del default_conf[key]
    default_conf["mail.on"] = True
    interface.start(default_conf)
예제 #24
0
파일: beakerd.py 프로젝트: omps/beaker
def schedule():
    global running

    interface.start(config)

    if config.get('carbon.address'):
        log.debug('starting metrics thread')
        metrics_thread = threading.Thread(target=metrics_loop, name='metrics')
        metrics_thread.daemon = True
        metrics_thread.start()

    beakerd_threads = set(["main_recipes"])

    log.debug("starting main recipes thread")
    main_recipes_thread = threading.Thread(target=main_recipes_loop,
                                           name="main_recipes")
    main_recipes_thread.daemon = True
    main_recipes_thread.start()

    try:
        while True:
            time.sleep(20)
            running_threads = set([t.name for t in threading.enumerate()])
            if not running_threads.issuperset(beakerd_threads):
                log.critical("a thread has died, shutting down")
                rc = 1
                running = False
                event.set()
                break
            event.set()
            event.clear()
    except (SystemExit, KeyboardInterrupt):
       log.info("shutting down")
       running = False
       event.set()
       rc = 0

    interface.stop()
    main_recipes_thread.join(10)

    sys.exit(rc)
예제 #25
0
def schedule():
    global running

    interface.start(config)

    if config.get('carbon.address'):
        log.debug('starting metrics thread')
        metrics_thread = threading.Thread(target=metrics_loop, name='metrics')
        metrics_thread.daemon = True
        metrics_thread.start()

    beakerd_threads = set(["main_recipes"])

    log.debug("starting main recipes thread")
    main_recipes_thread = threading.Thread(target=main_recipes_loop,
                                           name="main_recipes")
    main_recipes_thread.daemon = True
    main_recipes_thread.start()

    try:
        while True:
            time.sleep(20)
            running_threads = set([t.name for t in threading.enumerate()])
            if not running_threads.issuperset(beakerd_threads):
                log.critical("a thread has died, shutting down")
                rc = 1
                running = False
                event.set()
                break
            event.set()
            event.clear()
    except (SystemExit, KeyboardInterrupt):
        log.info("shutting down")
        running = False
        event.set()
        rc = 0

    interface.stop()
    main_recipes_thread.join(10)

    sys.exit(rc)
예제 #26
0
def setup_turbomail(config):
    from turbomail.control import interface

    cmap = {
        'smtp_server': 'mail.smtp.server',
        'smtp_username': '******',
        'smtp_password': '******',
        'smtp_use_tls': 'mail.smtp.tls'
    }

    boolkeys = ('mail.smtp.tls', 'mail.tls', 'mail.smtp.debug', 'mail.debug')

    for k, v in config.items():
        if k in cmap and cmap[k] not in config:
            config[cmap[k]] = v

    for k, v in config.items():
        if k.endswith('.on') or (k in boolkeys):
            config[k] = asbool(v)

    if config.get('mail.on'):
        interface.start(config)
예제 #27
0
def main(*args):
    parser = get_parser()
    (options, args) = parser.parse_args(*args)
    load_config_or_exit(options.configfile)
    log_to_stream(sys.stderr)
    interface.start(config)
    reservation_expiry = options.reservation_expiry
    reservation_length = options.reservation_length
    waiting_recipe_age = options.waiting_recipe_age
    delayed_job_age = options.delayed_job_age
    testing = options.testing

    if testing:
        print 'Dry run only, nothing will be sent\n'

    for user in User.query:
        beaker_usage = BeakerUsage(user, reservation_expiry,
                                   reservation_length, waiting_recipe_age,
                                   delayed_job_age)
        expiring_reservations = beaker_usage.expiring_reservations()
        open_in_demand_systems = beaker_usage.open_in_demand_systems()
        delayed_jobs = beaker_usage.delayed_jobs()
        if (expiring_reservations or open_in_demand_systems or delayed_jobs):
            data = {
                'user_name': user.user_name,
                'current_date': datetime.utcnow().strftime("%Y-%m-%d"),
                'beaker_fqdn': absolute_url('/'),
                'reservation_expiry': reservation_expiry,
                'reservation_length': reservation_length,
                'waiting_recipe_age': waiting_recipe_age,
                'delayed_job_age': delayed_job_age,
                'expiring_reservations': expiring_reservations,
                'open_reservations': open_in_demand_systems,
                'delayed_jobs': delayed_jobs
            }
            mail.send_usage_reminder(user, data, testing)
    return
예제 #28
0
def main(*args):
    parser = get_parser()
    (options, args) = parser.parse_args(*args)
    load_config_or_exit(options.configfile)
    log_to_stream(sys.stderr)
    interface.start(config)
    reservation_expiry = options.reservation_expiry
    reservation_length = options.reservation_length
    waiting_recipe_age = options.waiting_recipe_age
    delayed_job_age = options.delayed_job_age
    testing = options.testing

    if testing:
        print 'Dry run only, nothing will be sent\n'

    for user in User.query:
        beaker_usage = BeakerUsage(user, reservation_expiry, reservation_length,
                                   waiting_recipe_age, delayed_job_age)
        expiring_reservations = beaker_usage.expiring_reservations()
        open_in_demand_systems = beaker_usage.open_in_demand_systems()
        delayed_jobs = beaker_usage.delayed_jobs()
        if (expiring_reservations or open_in_demand_systems or delayed_jobs):
            data = {
                'user_name': user.user_name,
                'current_date': datetime.utcnow().strftime("%Y-%m-%d"),
                'beaker_fqdn': absolute_url('/'),
                'reservation_expiry': reservation_expiry,
                'reservation_length': reservation_length,
                'waiting_recipe_age': waiting_recipe_age,
                'delayed_job_age': delayed_job_age,
                'expiring_reservations': expiring_reservations,
                'open_reservations': open_in_demand_systems,
                'delayed_jobs': delayed_jobs
            }
            mail.send_usage_reminder(user, data, testing)
    return
예제 #29
0
def main(global_config, **settings):

    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(
        root_factory=Root, settings=settings,
        locale_negotiator=locale_negotiator,
        authentication_policy=create_authentication(settings)
    )
    # config.add_subscriber(add_cors_headers_response_callback, NewRequest)

    # overwrite print routes
    config.add_route(
        "lux_printproxy_report_create",
        "/printproxy/report.{format}",
        request_method="POST"
    )
    config.add_route(
        "lux_printproxy_status",
        "/printproxy/status/{ref}.json",
        request_method="GET"
    )
    config.add_route(
        "lux_printproxy_report_get",
        "/printproxy/report/{ref}",
        request_method="GET"
    )
    config.add_route(
        "lux_printproxy_report_cancel",
        "/printproxy/cancel/{ref}",
        request_method="DELETE"
    )
    # mymaps routes
    config.add_route(
        "mymaps",
        "/mymaps",
        request_method="HEAD"
    )
    config.add_route(
        "mymaps_image",
        "/",
        request_method="HEAD"
    )
    config.add_route(
        "mymaps_getcategories",
        "mymaps/categories",
        request_method="GET"
    )
    config.add_route(
        "mymaps_getallcategories",
        "mymaps/allcategories",
        request_method="GET"
    )

    config.add_route(
        "mymaps_getpublicmaps",
        "/mymaps/public_maps",
        request_method="GET"
    )
    config.add_route(
        "mymaps_getpublicategories",
        "/mymaps/public_categories",
        request_method="GET"
    )
    config.add_route(
        "mymaps_getmaps",
        "/mymaps/maps",
        request_method="GET"
    )
    config.add_route(
        "mymaps_features",
        "/mymaps/features/{map_id}",
        request_method="GET"
    )
    config.add_route(
        "mymaps_map_info",
        "/mymaps/map_info/{map_id}",
        request_method="GET"
    )

    config.add_route(
        "predefined_wms",
        "/predefined_wms",
        request_method="GET"
    )

    config.add_route(
        "mymaps_create",
        "/mymaps/create",
        request_method="POST"
    )
    config.add_route(
        "mymaps_rate",
        "/mymaps/rate/{map_id}"
    )
    config.add_route(
        "mymaps_update",
        "/mymaps/update/{map_id}",
        request_method="PUT"
    )
    config.add_route(
        "mymaps_map",
        "/mymaps/map/{map_id}",
        request_method="GET"
    )
    config.add_route(
        "mymaps_comment",
        "/mymaps/comment/{map_id}",
        request_method="POST"
    )
    config.add_route(
        "mymaps_upload_image",
        "/mymaps/upload_image",
        request_method="POST"
    )
    config.add_route(
        "mymaps_upload_symbol",
        "/mymaps/upload_symbol",
        request_method="POST"
    )
    config.add_route(
        "mymaps_get_image",
        "/mymaps/images/{filename}",
        request_method="GET"
    )
    config.add_route(
        "mymaps_get_symbol",
        "/mymaps/symbol/{symbol_id}",
        request_method="GET"
    )
    config.add_route(
        "mymaps_users_categories",
        "/mymaps/get_users_categories",
        request_method="GET"
    )
    config.add_route(
        "mymaps_get_symbols",
        "/mymaps/symbols",
        request_method="GET"
    )
    config.add_route(
        "mymaps_delete",
        "/mymaps/delete/{map_id}",
        request_method="DELETE"
    )
    config.add_route(
        "mymaps_delete_all_features",
        "/mymaps/delete_all_features/{map_id}",
        request_method="DELETE"
    )
    config.add_route(
        "mymaps_delete_feature",
        "/mymaps/delete_feature/{feature_id}",
        request_method="DELETE"
    )
    config.add_route(
        "mymaps_save_feature",
        "/mymaps/save_feature/{map_id}",
        request_method="POST"
    )
    config.add_route(
        "mymaps_save_features",
        "/mymaps/save_features/{map_id}",
        request_method="POST"
    )
    config.add_route(
        "mymaps_save_order",
        "/mymaps/save_order/{map_id}",
        request_method="POST"
    )
    config.add_route(
        "mymaps_copy",
        "/mymaps/copy/{map_id}",
        request_method="POST"
    )
    config.add_route(
        "exportgpxkml",
        "/mymaps/exportgpxkml",
        request_method="POST"
    )
    config.add_route(
        "get_arrow_color",
        "/mymaps/getarrow"
    )
    config.add_route(
        "getroute",
        "/mymaps/getroute"
    )
    config.add_route(
        "getremoteroute",
        "/router/getroute"
    )
    # geocoder routes
    config.add_route(
        "reverse_geocode",
        "/geocode/reverse"
    )
    config.add_route(
        "geocode",
        "/geocode/search"
    )
    config.add_route(
        "feedback",
        "/feedback"
    )
    # pag routes
    config.add_route(
        "pag_url",
        "/pag"
    )
    # pag routes
    config.add_route(
        "pag_report",
        "/pag/report/{oid}.pdf"
    )
    # pag routes
    config.add_route(
        "casipo_url",
        "/casipo"
    )
    # pag routes
    config.add_route(
        "casipo_report",
        "/casipo/report/{oid}.pdf"
    )
    # pds routes
    config.add_route(
        "pds_url",
        "/pds"
    )
    # pag routes
    config.add_route(
        "pds_report",
        "/pds/report/{oid}.pdf"
    )
    config.add_route(
        "pag_files",
        "/pag/files/{_file}"
    )
    config.add_route(
        "get_png",
        "/legends/get"
    )
    config.add_route(
        "get_html",
        "/legends/get_html"
    )

    # full text search routes
    config.add_route("fulltextsearch", "/fulltextsearch")

    # layer search routes
    config.add_route("layersearch", "/layersearch")

    # cms search routes
    config.add_route("cmssearch", "/cmssearch")

    # jsapi routes
    config.add_route(
        'jsapiloader',
        '/apiv3loader.js'
    )
    config.add_route(
        'jsapiexample',
        '/api-example'
    )
    config.add_route(
        'jsapilayers',
        '/jsapilayers'
    )

    config.include('c2cgeoportal')
    config.include('pyramid_closure')

    add_mako_renderer(config, '.appcache')

    config.add_translation_dirs('geoportailv3:locale/')

    # initialize database
    engines = config.get_settings()['sqlalchemy_engines']
    if engines:
        config.registry.dbmakers = {}
        for engine in engines:
            if 'url' not in engines[engine]:
                sqlahelper.add_engine(
                    sqlalchemy.create_engine(engines[engine]), name=engine)
            else:
                sqlahelper.add_engine(
                    sqlalchemy.create_engine(engines[engine]['url']),
                    name=engine)
            config.registry.dbmakers[engine] = sessionmaker(
                bind=sqlahelper.get_engine(engine))
            config.add_request_method(init_db(engine),
                                      'db_'+engine, reify=True)

    from geoportailv3.views.authentication import ldap_user_validator, \
        get_user_from_request
    ldap_settings = config.get_settings()['ldap']
    if ldap_settings:
        config.include('pyramid_ldap')

        """Config the ldap connection.
        """

        config.ldap_setup(
            ldap_settings['url'],
            ldap_settings['bind'],
            ldap_settings['passwd'],
        )

        config.ldap_set_login_query(
            ldap_settings['base_dn'],
            filter_tmpl='(login=%(login)s)',
            scope=ldap.SCOPE_SUBTREE,
            )

        config.set_request_property(
            get_user_from_request,
            name='user',
            reify=True
        )

        set_user_validator(config, ldap_user_validator)
    json_renderer = JSON()

    json_renderer.add_adapter(datetime.date, datetime_adapter)
    json_renderer.add_adapter(datetime.datetime, datetime_adapter)
    json_renderer.add_adapter(Decimal, decimal_adapter)
    config.add_renderer('json', json_renderer)

    mail_config = config.get_settings()['turbomail']
    if mail_config:
        interface.start(mail_config)

    # scan view decorator for adding routes
    config.scan()

    # add the interfaces
    add_interface(config, interface_type=INTERFACE_TYPE_NGEO_CATALOGUE)

    config.add_route("echocsv", "/profile/echocsv", request_method="POST")
    config.add_route('getuserinfo', '/getuserinfo')
    config.add_route('wms', '/ogcproxywms')
    config.add_route('https_proxy', '/httpsproxy')
    config.add_route('download_sketch', '/downloadsketch')
    config.add_route('download', '/download')
    config.add_route('download_measurement', '/downloadmeasurement')
    config.add_route('preview_measurement', '/previewmeasurement')
    config.add_route('qr', '/qr')
    config.add_route('getfeatureinfo', '/getfeatureinfo')
    config.add_route('getpoitemplate', '/getpoitemplate')
    config.add_route('getremotetemplate', '/getremotetemplate')
    config.add_route('isthemeprivate', '/isthemeprivate')
    config.add_route('download_resource', '/downloadresource')

    # Appcache manifest
    config.add_route(
        'appcache',
        '/geoportailv3.appcache'
    )

    return config.make_wsgi_app()
 def test_dont_fail_if_no_extra_classes_were_provided(self):
     interface.start(self.config)
예제 #31
0
파일: email.py 프로젝트: Cowoop/cowspa3
 def start(self):
     interface.start(self.config)
예제 #32
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(
        root_factory=Root, settings=settings,
        locale_negotiator=locale_negotiator,
        authentication_policy=create_authentication(settings)
    )

    # overwrite print routes
    config.add_route(
        "lux_printproxy_report_create",
        "/printproxy/report.{format}",
        request_method="POST"
    )
    config.add_route(
        "lux_printproxy_report_get",
        "/printproxy/report/{ref}",
        request_method="GET"
    )
    config.add_route(
        "lux_printproxy_report_cancel",
        "/printproxy/cancel/{ref}",
        request_method="DELETE"
    )
    # mymaps routes
    config.add_route(
        "mymaps",
        "/mymaps",
        request_method="HEAD"
    )
    config.add_route(
        "mymaps_image",
        "/",
        request_method="HEAD"
    )
    config.add_route(
        "mymaps_getcategories",
        "mymaps/categories",
        request_method="GET"
    )
    config.add_route(
        "mymaps_getmaps",
        "/mymaps/maps",
        request_method="GET"
    )
    config.add_route(
        "mymaps_features",
        "/mymaps/features/{map_id}",
        request_method="GET"
    )
    config.add_route(
        "mymaps_map_info",
        "/mymaps/map_info/{map_id}",
        request_method="GET"
    )

    config.add_route(
        "mymaps_create",
        "/mymaps/create",
        request_method="POST"
    )
    config.add_route(
        "mymaps_rate",
        "/mymaps/rate/{map_id}"
    )
    config.add_route(
        "mymaps_update",
        "/mymaps/update/{map_id}",
        request_method="PUT"
    )
    config.add_route(
        "mymaps_map",
        "/mymaps/map/{map_id}",
        request_method="GET"
    )
    config.add_route(
        "mymaps_comment",
        "/mymaps/comment/{map_id}",
        request_method="POST"
    )
    config.add_route(
        "mymaps_upload_image",
        "/mymaps/upload_image",
        request_method="POST"
    )
    config.add_route(
        "mymaps_upload_symbol",
        "/mymaps/upload_symbol",
        request_method="POST"
    )
    config.add_route(
        "mymaps_get_image",
        "/mymaps/images/{filename}",
        request_method="GET"
    )
    config.add_route(
        "mymaps_get_symbol",
        "/mymaps/symbol/{symbol_id}",
        request_method="GET"
    )
    config.add_route(
        "mymaps_get_symbols",
        "/mymaps/symbols",
        request_method="GET"
    )
    config.add_route(
        "mymaps_delete",
        "/mymaps/delete/{map_id}",
        request_method="DELETE"
    )
    config.add_route(
        "mymaps_delete_all_features",
        "/mymaps/delete_all_features/{map_id}",
        request_method="DELETE"
    )
    config.add_route(
        "mymaps_delete_feature",
        "/mymaps/delete_feature/{feature_id}",
        request_method="DELETE"
    )
    config.add_route(
        "mymaps_save_feature",
        "/mymaps/save_feature/{map_id}",
        request_method="POST"
    )
    config.add_route(
        "mymaps_save_features",
        "/mymaps/save_features/{map_id}",
        request_method="POST"
    )
    config.add_route(
        "mymaps_copy",
        "/mymaps/copy/{map_id}",
        request_method="POST"
    )
    config.add_route(
        "exportgpxkml",
        "/mymaps/exportgpxkml",
        request_method="POST"
    )
    # geocoder routes
    config.add_route(
        "reverse_geocode",
        "/geocode/reverse"
    )
    # pag routes
    config.add_route(
        "pag_url",
        "/pag"
    )
    # pag routes
    config.add_route(
        "pag_report",
        "/pag/report/{oid}.pdf"
    )
    config.add_route(
        "pag_files",
        "/pag/files/{_file}"
    )

    # full text search routes
    config.add_route("fulltextsearch", "/fulltextsearch")

    # layer search routes
    config.add_route("layersearch", "/layersearch")

    config.include('c2cgeoportal')
    config.include('pyramid_closure')

    config.add_translation_dirs('geoportailv3:locale/')

    # initialize database
    engines = config.get_settings()['sqlalchemy_engines']
    if engines:
        for engine in engines:
            sqlahelper.add_engine(
                sqlalchemy.create_engine(engines[engine]), name=engine)

    from geoportailv3.views.authentication import ldap_user_validator, \
        get_user_from_request
    ldap_settings = config.get_settings()['ldap']
    if False:
        config.include('pyramid_ldap')

        """Config the ldap connection.
        """

        config.ldap_setup(
            ldap_settings['url'],
            ldap_settings['bind'],
            ldap_settings['passwd'],
        )

        config.ldap_set_login_query(
            ldap_settings['base_dn'],
            filter_tmpl='(login=%(login)s)',
            scope=ldap.SCOPE_SUBTREE,
            )

        config.set_request_property(
            get_user_from_request,
            name='user',
            reify=True
        )

        set_user_validator(config, ldap_user_validator)
    json_renderer = JSON()

    json_renderer.add_adapter(datetime.date, datetime_adapter)
    json_renderer.add_adapter(datetime.datetime, datetime_adapter)
    json_renderer.add_adapter(Decimal, decimal_adapter)
    config.add_renderer('json', json_renderer)

    mail_config = config.get_settings()['turbomail']
    if mail_config:
        interface.start(mail_config)

    # scan view decorator for adding routes
    config.scan()

    # add the interfaces
    add_interface(config, interface_type=INTERFACE_TYPE_NGEO_CATALOGUE)

    config.add_route("echocsv", "/profile/echocsv", request_method="POST")
    config.add_route('getuserinfo', '/getuserinfo')
    config.add_route('wms', '/ogcproxywms')
    config.add_route('download_sketch', '/downloadsketch')
    config.add_route('download_measurement', '/downloadmeasurement')
    config.add_route('qr', '/qr')
    config.add_route('getfeatureinfo', '/getfeatureinfo')
    config.add_route('getpoitemplate', '/getpoitemplate')
    config.add_route('getremotetemplate', '/getremotetemplate')
    config.add_route('isthemeprivate', '/isthemeprivate')
    return config.make_wsgi_app()
예제 #33
0
def main(global_config, **settings):

    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(
        root_factory=Root, settings=settings,
        locale_negotiator=locale_negotiator,
        authentication_policy=create_authentication(settings)
    )
    # config.add_subscriber(add_cors_headers_response_callback, NewRequest)

    # overwrite print routes
    config.add_route(
        "lux_printproxy_report_create",
        "/printproxy/report.{format}",
        request_method="POST"
    )
    config.add_route(
        "lux_printproxy_status",
        "/printproxy/status/{ref}.json",
        request_method="GET"
    )
    config.add_route(
        "lux_printproxy_report_get",
        "/printproxy/report/{ref}",
        request_method="GET"
    )
    config.add_route(
        "lux_printproxy_report_cancel",
        "/printproxy/cancel/{ref}",
        request_method="DELETE"
    )
    # mymaps routes
    config.add_route(
        "mymaps",
        "/mymaps",
        request_method="HEAD"
    )
    config.add_route(
        "mymaps_image",
        "/",
        request_method="HEAD"
    )
    config.add_route(
        "mymaps_getcategories",
        "mymaps/categories",
        request_method="GET"
    )
    config.add_route(
        "mymaps_getallcategories",
        "mymaps/allcategories",
        request_method="GET"
    )

    config.add_route(
        "generate_symbol_file",
        "/mymaps/generate_symbol_file",
        request_method="GET"
    )

    config.add_route(
        "mymaps_getpublicmaps",
        "/mymaps/public_maps",
        request_method="GET"
    )
    config.add_route(
        "mymaps_getpublicategories",
        "/mymaps/public_categories",
        request_method="GET"
    )
    config.add_route(
        "mymaps_getmaps",
        "/mymaps/maps",
        request_method="GET"
    )
    config.add_route(
        "mymaps_features",
        "/mymaps/features/{map_id}",
        request_method="GET"
    )
    config.add_route(
        "mymaps_map_info",
        "/mymaps/map_info/{map_id}",
        request_method="GET"
    )

    config.add_route(
        "predefined_wms",
        "/predefined_wms",
        request_method="GET"
    )

    config.add_route(
        "mymaps_create",
        "/mymaps/create",
        request_method="POST"
    )
    config.add_route(
        "mymaps_rate",
        "/mymaps/rate/{map_id}"
    )
    config.add_route(
        "mymaps_update",
        "/mymaps/update/{map_id}",
        request_method="PUT"
    )
    config.add_route(
        "mymaps_map",
        "/mymaps/map/{map_id}",
        request_method="GET"
    )
    config.add_route(
        "mymaps_comment",
        "/mymaps/comment/{map_id}",
        request_method="POST"
    )
    config.add_route(
        "mymaps_upload_image",
        "/mymaps/upload_image",
        request_method="POST"
    )
    config.add_route(
        "mymaps_upload_symbol",
        "/mymaps/upload_symbol",
        request_method="POST"
    )
    config.add_route(
        "mymaps_get_image",
        "/mymaps/images/{filename}",
        request_method="GET"
    )
    config.add_route(
        "mymaps_get_symbol",
        "/mymaps/symbol/{symbol_id}",
        request_method="GET"
    )
    config.add_route(
        "mymaps_users_categories",
        "/mymaps/get_users_categories",
        request_method="GET"
    )
    config.add_route(
        "mymaps_get_symbols",
        "/mymaps/symbols",
        request_method="GET"
    )
    config.add_route(
        "mymaps_delete",
        "/mymaps/delete/{map_id}",
        request_method="DELETE"
    )
    config.add_route(
        "mymaps_delete_all_features",
        "/mymaps/delete_all_features/{map_id}",
        request_method="DELETE"
    )
    config.add_route(
        "mymaps_delete_feature",
        "/mymaps/delete_feature/{feature_id}",
        request_method="DELETE"
    )
    config.add_route(
        "mymaps_save_feature",
        "/mymaps/save_feature/{map_id}",
        request_method="POST"
    )
    config.add_route(
        "mymaps_save_features",
        "/mymaps/save_features/{map_id}",
        request_method="POST"
    )
    config.add_route(
        "mymaps_save_order",
        "/mymaps/save_order/{map_id}",
        request_method="POST"
    )
    config.add_route(
        "mymaps_copy",
        "/mymaps/copy/{map_id}",
        request_method="POST"
    )
    config.add_route(
        "exportgpxkml",
        "/mymaps/exportgpxkml",
        request_method="POST"
    )
    config.add_route(
        "get_arrow_color",
        "/mymaps/getarrow"
    )
    config.add_route(
        "getroute",
        "/mymaps/getroute"
    )
    config.add_route(
        "getremoteroute",
        "/router/getroute"
    )
    # geocoder routes
    config.add_route(
        "reverse_geocode",
        "/geocode/reverse"
    )
    config.add_route(
        "geocode",
        "/geocode/search"
    )
    config.add_route(
        "feedback",
        "/feedback"
    )
    config.add_route(
        "feedbackanf",
        "/feedbackanf"
    )
    # pag routes
    config.add_route(
        "pag_url",
        "/pag"
    )
    # pag routes
    config.add_route(
        "pag_report",
        "/pag/report/{oid}.pdf"
    )
    # pag routes
    config.add_route(
        "casipo_url",
        "/casipo"
    )
    # pag routes
    config.add_route(
        "casipo_report",
        "/casipo/report/{oid}.pdf"
    )
    # pds routes
    config.add_route(
        "pds_url",
        "/pds"
    )
    # pag routes
    config.add_route(
        "pds_report",
        "/pds/report/{oid}.pdf"
    )
    config.add_route(
        "pag_files",
        "/pag/files/{_file}"
    )
    config.add_route(
        "get_png",
        "/legends/get"
    )
    config.add_route(
        "get_html",
        "/legends/get_html"
    )

    # full text search routes
    config.add_route("fulltextsearch", "/fulltextsearch")

    # layer search routes
    config.add_route("layersearch", "/layersearch")

    # cms search routes
    config.add_route("cmssearch", "/cmssearch")

    # jsapi routes
    config.add_route(
        'jsapiloader',
        '/apiv3loader.js'
    )
    config.add_route(
        'jsapiexample',
        '/api-example'
    )
    config.add_route(
        'jsapilayers',
        '/jsapilayers'
    )

    config.include('c2cgeoportal')
    config.include('pyramid_closure')

    add_mako_renderer(config, '.appcache')

    config.add_translation_dirs('geoportailv3:locale/')

    # initialize database
    engines = config.get_settings()['sqlalchemy_engines']
    if engines:
        config.registry.dbmakers = {}
        for engine in engines:
            if 'url' not in engines[engine]:
                sqlahelper.add_engine(
                    sqlalchemy.create_engine(engines[engine]), name=engine)
            else:
                sqlahelper.add_engine(
                    sqlalchemy.create_engine(engines[engine]['url']),
                    name=engine)
            config.registry.dbmakers[engine] = sessionmaker(
                bind=sqlahelper.get_engine(engine))
            config.add_request_method(init_db(engine),
                                      'db_'+engine, reify=True)

    from geoportailv3.views.authentication import ldap_user_validator, \
        get_user_from_request
    ldap_settings = config.get_settings()['ldap']
    if ldap_settings:
        config.include('pyramid_ldap')

        """Config the ldap connection.
        """

        config.ldap_setup(
            ldap_settings['url'],
            ldap_settings['bind'],
            ldap_settings['passwd'],
        )

        config.ldap_set_login_query(
            ldap_settings['base_dn'],
            filter_tmpl='(login=%(login)s)',
            scope=ldap.SCOPE_SUBTREE,
            )

        config.set_request_property(
            get_user_from_request,
            name='user',
            reify=True
        )

        set_user_validator(config, ldap_user_validator)
    json_renderer = JSON()

    json_renderer.add_adapter(datetime.date, datetime_adapter)
    json_renderer.add_adapter(datetime.datetime, datetime_adapter)
    json_renderer.add_adapter(Decimal, decimal_adapter)
    config.add_renderer('json', json_renderer)

    mail_config = config.get_settings()['turbomail']
    if mail_config:
        interface.start(mail_config)

    # scan view decorator for adding routes
    config.scan()

    # add the interfaces
    add_interface(config, interface_type=INTERFACE_TYPE_NGEO_CATALOGUE)

    config.add_route("echocsv", "/profile/echocsv", request_method="POST")
    config.add_route('getuserinfo', '/getuserinfo')
    config.add_route('wms', '/ogcproxywms')
    config.add_route('https_proxy', '/httpsproxy')
    config.add_route('download_sketch', '/downloadsketch')
    config.add_route('download', '/download')
    config.add_route('download_measurement', '/downloadmeasurement')
    config.add_route('preview_measurement', '/previewmeasurement')
    config.add_route('qr', '/qr')
    config.add_route('getfeatureinfo', '/getfeatureinfo')
    config.add_route('getpoitemplate', '/getpoitemplate')
    config.add_route('getremotetemplate', '/getremotetemplate')
    config.add_route('isthemeprivate', '/isthemeprivate')
    config.add_route('download_resource', '/downloadresource')

    # Appcache manifest
    config.add_route(
        'appcache',
        '/geoportailv3.appcache'
    )

    return config.make_wsgi_app()
예제 #34
0
파일: tg1.py 프로젝트: mbbui/Jminee
def start_extension():
    # interface.start will exit immediately if TurboMail is not enabled.
    interface.start(config)
예제 #35
0
def main(global_config, **settings):
    """ This function returns a Pyramid WSGI application.
    """
    config = Configurator(
        root_factory=Root,
        settings=settings,
        locale_negotiator=locale_negotiator,
        authentication_policy=create_authentication(settings))

    # overwrite print routes
    config.add_route("lux_printproxy_report_create",
                     "/printproxy/report.{format}",
                     request_method="POST")
    config.add_route("lux_printproxy_report_get",
                     "/printproxy/report/{ref}",
                     request_method="GET")
    config.add_route("lux_printproxy_report_cancel",
                     "/printproxy/cancel/{ref}",
                     request_method="DELETE")
    # mymaps routes
    config.add_route("mymaps", "/mymaps", request_method="HEAD")
    config.add_route("mymaps_image", "/", request_method="HEAD")
    config.add_route("mymaps_getcategories",
                     "mymaps/categories",
                     request_method="GET")
    config.add_route("mymaps_getmaps", "/mymaps/maps", request_method="GET")
    config.add_route("mymaps_features",
                     "/mymaps/features/{map_id}",
                     request_method="GET")
    config.add_route("mymaps_map_info",
                     "/mymaps/map_info/{map_id}",
                     request_method="GET")

    config.add_route("mymaps_create", "/mymaps/create", request_method="POST")
    config.add_route("mymaps_rate", "/mymaps/rate/{map_id}")
    config.add_route("mymaps_update",
                     "/mymaps/update/{map_id}",
                     request_method="PUT")
    config.add_route("mymaps_map",
                     "/mymaps/map/{map_id}",
                     request_method="GET")
    config.add_route("mymaps_comment",
                     "/mymaps/comment/{map_id}",
                     request_method="POST")
    config.add_route("mymaps_upload_image",
                     "/mymaps/upload_image",
                     request_method="POST")
    config.add_route("mymaps_upload_symbol",
                     "/mymaps/upload_symbol",
                     request_method="POST")
    config.add_route("mymaps_get_image",
                     "/mymaps/images/{filename}",
                     request_method="GET")
    config.add_route("mymaps_get_symbol",
                     "/mymaps/symbol/{symbol_id}",
                     request_method="GET")
    config.add_route("mymaps_get_symbols",
                     "/mymaps/symbols",
                     request_method="GET")
    config.add_route("mymaps_delete",
                     "/mymaps/delete/{map_id}",
                     request_method="DELETE")
    config.add_route("mymaps_delete_all_features",
                     "/mymaps/delete_all_features/{map_id}",
                     request_method="DELETE")
    config.add_route("mymaps_delete_feature",
                     "/mymaps/delete_feature/{feature_id}",
                     request_method="DELETE")
    config.add_route("mymaps_save_feature",
                     "/mymaps/save_feature/{map_id}",
                     request_method="POST")
    config.add_route("mymaps_save_features",
                     "/mymaps/save_features/{map_id}",
                     request_method="POST")
    config.add_route("mymaps_copy",
                     "/mymaps/copy/{map_id}",
                     request_method="POST")
    config.add_route("exportgpxkml",
                     "/mymaps/exportgpxkml",
                     request_method="POST")
    # geocoder routes
    config.add_route("reverse_geocode", "/geocode/reverse")
    # pag routes
    config.add_route("pag_url", "/pag")
    # pag routes
    config.add_route("pag_report", "/pag/report/{oid}.pdf")
    config.add_route("pag_files", "/pag/files/{_file}")

    config.include('c2cgeoportal')
    config.include('pyramid_closure')

    config.add_translation_dirs('geoportailv3:locale/')

    # initialize database
    engines = config.get_settings()['sqlalchemy_engines']
    if engines:
        for engine in engines:
            sqlahelper.add_engine(sqlalchemy.create_engine(engines[engine]),
                                  name=engine)

    from geoportailv3.views.authentication import ldap_user_validator, \
        get_user_from_request
    ldap_settings = config.get_settings()['ldap']
    if ldap_settings:
        config.include('pyramid_ldap')
        """Config the ldap connection.
        """

        config.ldap_setup(
            ldap_settings['url'],
            ldap_settings['bind'],
            ldap_settings['passwd'],
        )

        config.ldap_set_login_query(
            ldap_settings['base_dn'],
            filter_tmpl='(login=%(login)s)',
            scope=ldap.SCOPE_SUBTREE,
        )

        config.set_request_property(get_user_from_request,
                                    name='user',
                                    reify=True)

        set_user_validator(config, ldap_user_validator)
    json_renderer = JSON()

    json_renderer.add_adapter(datetime.date, datetime_adapter)
    json_renderer.add_adapter(datetime.datetime, datetime_adapter)
    json_renderer.add_adapter(Decimal, decimal_adapter)
    config.add_renderer('json', json_renderer)

    mail_config = config.get_settings()['turbomail']
    if mail_config:
        interface.start(mail_config)

    # scan view decorator for adding routes
    config.scan()

    # add the interfaces
    add_interface(config, interface_type=INTERFACE_TYPE_NGEO_CATALOGUE)

    config.add_route("echocsv", "/profile/echocsv", request_method="POST")
    config.add_route('getuserinfo', '/getuserinfo')
    config.add_route('wms', '/ogcproxywms')
    config.add_route('download_sketch', '/downloadsketch')
    config.add_route('download_measurement', '/downloadmeasurement')
    config.add_route('qr', '/qr')
    config.add_route('getfeatureinfo', '/getfeatureinfo')
    config.add_route('getpoitemplate', '/getpoitemplate')
    config.add_route('getremotetemplate', '/getremotetemplate')
    config.add_route('isthemeprivate', '/isthemeprivate')
    return config.make_wsgi_app()
예제 #36
0
    ~~~~~~~~~~~~~~~~~~~

    Using TurboMail with Flask
    http://flask.pocoo.org/snippets/16/
"""

import atexit

from turbomail.control import interface
from turbomail.message import Message

from flask import Flask

# pass in dict of config options

interface.start({'mail.on' : True})

# ensures interface cleanly shutdown when process exits

atexit.register(interface.stop, force=True)

app = Flask(__name__)

@app.route("/")
def index():
    # send an email
    msg = Message("*****@*****.**",
                  "*****@*****.**",
                  "a subject")
    msg.plain = "body of message"
    msg.send()