def send(recpt_box_id, uname, pwd, subj, attachements): """ attachements: list of tuples of (mime, description, content) """ ds_client = None try: # create the client ds_client = Client(login_method='username', login=uname, password=pwd, test_environment=False) return _create_message(ds_client, recpt_box_id, subj, attachements) finally: if ds_client: ds_client.logout_from_server()
parser.add_option('-u', '--username', action='store', dest='uname', help='uzivatelske jmeno k tvoji DS',) parser.add_option('-p', '--pwd', action='store', dest='pwd', help='heslo k tvoji DS',) (options, args) = parser.parse_args() if len(args) != 1: parser.error('wrong number of arguments') logging.basicConfig(level=logging.INFO) logging.getLogger('suds').setLevel(logging.ERROR) query = args[0].decode('utf-8') logging.info("searching for %s ..." % query) try: # create the client ds_client = Client(login_method='username', login=options.uname, password=options.pwd, test_environment=False) create_message(ds_client, query) except Exception, e: logging.error(str(e)) finally: ds_client.logout_from_server()
'--pwd', action='store', dest='pwd', help='heslo k tvoji DS', ) (options, args) = parser.parse_args() if len(args) != 1: parser.error('wrong number of arguments') logging.basicConfig(level=logging.INFO) logging.getLogger('suds').setLevel(logging.ERROR) query = args[0].decode('utf-8') logging.info("searching for %s ..." % query) try: # create the client ds_client = Client(login_method='username', login=options.uname, password=options.pwd, test_environment=False) create_message(ds_client, query) except Exception, e: logging.error(str(e)) finally: ds_client.logout_from_server()