コード例 #1
0
def Sneeze(*args, **kwargs):
    path = ""
    # if user supplies a destination as an argument, use that
    if args[0].confpath:
        path = args[0].confpath
    configuration = configure.Configure(path=path)
    # create event handler
    # dictionary contains mapping of interface to path and pattern
    # HayFever must verify which path and pattern an event matches
    # and include the relevant interface in the event
    event_handler = HayFever(**configuration.confdata)

    threads = []
    observer = Observer()

    for interface, values in configuration.confdata['watch'].items():
        print >> sys.stderr, "Watching directory {}".format(values['path'])
        # create event detector
        observer.schedule(event_handler, values['path'], recursive=True)
        threads.append(observer)

    print >> sys.stderr, "Starting watcher..."
    observer.start()
    print >> sys.stderr, "Watcher started"
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()
コード例 #2
0
def gen_config( dst, src, zone_name, template ):
	zone_name = str(zone_name);
	srcpath = src + zone_name + ".json";
	if not os.path.exists(srcpath):
		print "%s.json not found" % (zone_name);
		return -1;

	print "start out config:" + zone_name;
	dstpath=dst + "/" + zone_name + "/";
	if os.path.exists(dstpath) == False:
		os.mkdir(dstpath);

	cfg = configure.Configure(srcpath);
	cfg.prepare();
	data = cfg.get_data();
	template.write_config( data, dstpath );

	# gen db install.bat
	db_install = dstpath + "db_install.bat";
	db = open(db_install, 'wb');
	db.write(
'''@echo off
rem copy this file to sql directory
onekey %s %s %s %d %d %d
''' % (data["db_user"], data["db_pwd"], data["db_host"], data["db_port"], data["GameZoneID"], data["GameZoneID"]) );
	db.close();
	return 0;
コード例 #3
0
 def setUp(self):
     self.configure = configure.Configure(
             account_sid="ACxxxxx",
             auth_token="yyyyyyyy",
             phone_number="+15555555555",
             app_sid="APzzzzzzzzz")
     self.configure.client = TwilioRestClient(self.configure.account_sid,
             self.configure.auth_token)
コード例 #4
0
 def test_configureWithoutAuthToken(self):
     test = configure.Configure(account_sid='ACxxxxxxx', auth_token=None,
             phone_number=None, app_sid=None)
     self.assertRaises(configure.ConfigurationError,
             test.start)
コード例 #5
0
ファイル: test_configure.py プロジェクト: dwservice/agent
# -*- coding: utf-8 -*-
'''
This Source Code Form is subject to the terms of the Mozilla
Public License, v. 2.0. If a copy of the MPL was not distributed
with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
'''
import sys
import os
import configure

if __name__ == "__main__":
    i = configure.Configure()
    i._set_config_base_path(".." + os.sep + "core")
    i.start()
    sys.exit(0)
コード例 #6
0
ファイル: main.py プロジェクト: tomeasure/TestMail
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.header import Header
import configure as conf

kfg = conf.Configure()

mail_host = kfg.getHost()
mail_user = kfg.getUser()
mail_pass = kfg.getPass()
mail_port = kfg.getPort()
sender = kfg.getSender()
receiver = kfg.getReceiver()

message = MIMEMultipart()
message['From'] = Header(kfg.getFrom(), 'utf-8')
message['To'] = Header(kfg.getTo(), 'utf-8')
message['Subject'] = Header(kfg.getSubject, 'utf-8')
att = MIMEText(open('parse_xml.py', 'rb').read(), 'base64', 'utf-8')
att['Content-Type'] = 'application/octet-stream'
att['Content-Disposition'] = 'attachment;filename="parse_xml.py"'
message.attach(att)

smtpObj = smtplib.SMTP()
print('connecting...')
smtpObj.connect(mail_host, mail_port)
print('login...')
smtpObj.starttls(
)  # 防止出现 smtplib.SMTPAuthenticationError: (530, b'Must issue a STARTTLS command first.') 异常
smtpObj.login(mail_user, mail_pass)
コード例 #7
0
def Configure(path):
    return configure.Configure(path)
コード例 #8
0
 def __init__():
     firstline=a
     lastline=a
     linenum=0
     configure=configure.Configure()
コード例 #9
0
 def __init__(self):
     # 准备配置信息...
     self.kfg = conf.Configure()
     self.cd = self.kfg.createConfigureData()
     # 准备发送的信息...
     self.message = self.createMessage()
コード例 #10
0
 def createCD(self):
     kfg = conf.Configure()
     return kfg.createConfigureData()