Esempio n. 1
0
def print_basic_columns(users):
    # print len(users)
    usrList = UsrObjList()
    for user in users:
        usrList.append(user)
        # SanitationUtils.safe_print( "BILLING ADDRESS:", repr(user), user['First Name'], user.get('First Name'), user.name.__unicode__(out_schema="flat"))

    cols = col_data.get_col_data_native('basic')

    SanitationUtils.safe_print(usrList.tabulate(cols, tablefmt='simple'))
Esempio n. 2
0
ascii_str = SanitationUtils.unicode_to_ascii(u_str)
ascii_back = SanitationUtils.ascii_to_unicode(u_str)

printandrep("u_str", u_str)
printandrep("utf8_str", utf8_str, utf8_back)
printandrep("xml_str", xml_str, xml_back)
printandrep("ascii_str", ascii_str, ascii_back)

print SanitationUtils.unicode_to_utf8(None)
print SanitationUtils.utf8_to_unicode(None)
print SanitationUtils.unicode_to_xml(None)
print SanitationUtils.xml_to_unicode(None)
print SanitationUtils.unicode_to_ascii(None)
print SanitationUtils.ascii_to_unicode(None)
print SanitationUtils.coerce_unicode(None)
SanitationUtils.safe_print(None)

print converters.to_bytes(SanitationUtils.coerce_unicode("\xf0\x9f\x91\x8c"))

print converters.to_bytes(
    SanitationUtils.unicode_to_xml("\xf0\x9f\x91\x8c".decode("utf8"), True))
print converters.xml_to_unicode("L")
print converters.xml_to_byte_string("L")
print converters.to_bytes(converters.xml_to_unicode("と"))
print converters.to_bytes(
    converters.xml_to_byte_string("と", input_encoding="ascii"))
print converters.xml_to_unicode("👌", encoding="ascii")
print converters.xml_to_byte_string("👌", input_encoding="ascii")

map_json = '{"E-mail":"*****@*****.**","Web Site":"http:\/\/technotan.com.au","MYOB Customer Card ID":[""],"MYOB Card ID":[""],"First Name":["Neil \ud83d\udc4c\'&>"],"Surname":["Cunliffe-Williams"],"Contact":["Neil Cunliffe-Williams"],"Company":["Laserphile"],"Address 1":["7 Grosvenor Road"],"Address 2":[""],"City":[""],"Postcode":["6053"],"State":["WA"],"Phone":["0416160912"],"Home Address 1":["7 Grosvenor Road"],"Home Address 2":[""],"Home City":["Bayswater"],"Home Postcode":["6053"],"Home Country":["AU"],"Home State":["WA"],"Role":["ADMIN"],"ABN":["32"],"Business Type":[""],"Birth Date":[""],"Mobile Phone":["+61416160912"],"Fax":[""],"Lead Source":[""],"Referred By":[""]}'
Esempio n. 3
0
sshClient = paramiko.SSHClient()
sshClient.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
    sshClient.connect(**paramikoSSHParams)
    stdin, stdout, stderr = sshClient.exec_command(command)
    possible_errors = stdout.readlines()
    assert not possible_errors, "command returned errors: " + possible_errors
    try:
        sftp_client = sshClient.open_sftp()
        sftp_client.chdir(remote_export_folder)
        fstat = sftp_client.stat(exportFilename)
        if fstat:
            sftp_client.get(exportFilename, ma_path)
    except Exception as exc:
        SanitationUtils.safe_print("ERROR IN SFTP: " + str(exc))
    finally:
        sftp_client.close()

except Exception as exc:
    SanitationUtils.safe_print("ERROR IN SSH: " + str(exc))
finally:
    sshClient.close()

ma_parser = CsvParseUser(
    cols=col_data.get_import_cols(),
    defaults=col_data.get_defaults(),
    contact_schema='act',
)

ma_parser.analyse_file(ma_path, maEncoding)
Esempio n. 4
0

username = '******'
password = '******'
store_url = 'http://minimac.ddns.me:11182/'

# store_url = 'http://technotea.com.au/'
# username = '******'
# password = '******'
xmlrpc_uri = store_url + 'xmlrpc.php'

client = Client(xmlrpc_uri, username, password)
# posts = client.call(posts.GetPosts())
# print posts

# print client.normalize_string(u'no\u2015odle')

fields = {
    'first_name': 'no👌od👌le'.decode('utf8'),
    'user_url': "http://www.laserphile.com/",
    'user_login': "******"
}
fields_json = SanitationUtils.encode_json(fields)
SanitationUtils.safe_print(repr(fields_json))
# fields_json_base64 = SanitationUtils.encode_base64( fields_json )
fields_json_base64 = "eyJidXNpbmVzc190eXBlIjogIk90aGVyIiwgInByZWZfdGVsIjogIkZhbHNlIiwgImFjdF9yb2xlIjogIlJOIiwgInByZWZfbW9iIjogIkZhbHNlIiwgImhvd19oZWFyX2Fib3V0IjogIkV2ZW50IiwgInVzZXJfZW1haWwiOiAiZW1tYS1hbGxlbjk0QGhvdG1haWwuY29tIn0="
# print fields_json_base64
# eyJ1c2VyX2xvZ2luIjogImFkbWluIiwgImZpcnN0X25hbWUiOiAibm_wn5GMb2Twn5GMbGUiLCAidXNlcl91cmwiOiAiaHR0cDovL3d3dy5sYXNlcnBoaWxlLmNvbS8ifQ==
test_out = client.call(UpdateUser(1, fields_json_base64))
print test_out