def handle(self, *args, **options): if len(args) < 2: raise CommandError("Usage: manage.py submit_forms <directory> <post url>") dir = args[0] url = args[1] for file in os.listdir(dir): print post_file(os.path.join(dir, file), url)
def handle(self, *args, **options): if len(args) < 2: raise CommandError( 'Usage: manage.py submit_forms <directory> <post url>') dir = args[0] url = args[1] for file in os.listdir(dir): print post_file(os.path.join(dir, file), url)
def handle(self, *args, **options): if len(args) < 2: raise CommandError('Usage: manage.py post_from <file> <post url>') file = args[0] url = args[1] resp, errors = post_file(file, url) print "Got response:\n%s" % resp
def handle(self, file, url, **options): resp, errors = post_file(file, url) print("Got response:\n%s" % resp)
from dimagi.utils.post import post_file DELETE_DB = False # server object server = Server() if DELETE_DB: try: server.delete_db("patient") except: pass # create database db = server.get_or_create_db("patient") # load views # loader = FileSystemDocsLoader("../apps/xforms/_design") # loader.sync(db, verbose=True) filenames = ["data/brac_reg.xml", "data/demo_form.xml", "data/no_uuid_form.xml", "data/no_xmlns_form.xml"] for filename in filenames: id = uuid.uuid4() with open(filename, "rb") as f: xml_data = f.read() xml_data = xml_data.replace("REPLACE_ME", str(id)) tmp_file_path = tempfile.TemporaryFile().name try: tmp_file = open(tmp_file_path, "w") tmp_file.write(xml_data) finally: tmp_file.close() print post_file(tmp_file_path, "http://localhost:5984/patient/_design/xforms/_update/xform/")
def handle(self, directory, post_url, **options): for file in os.listdir(directory): print(post_file(os.path.join(directory, file), post_url))
import sys, os ###################### #POST_URL = "http://localhost:5984/bhoma_test/_design/xforms/_update/xform/" POST_URL = "http://localhost:8000/a/cory2/receiver/" #POST_URL = "http://bhoma.dimagi.com/phone/post/" sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) from dimagi.utils.post import post_file, post_authenticated_file # path = os.path.join(os.path.dirname(os.path.dirname(__file__)), "instances", "chw_follow_test_2.xml") #path = r"C:\Users\czue\source\bhomalite\bhoma\apps\case\tests\data\bhoma\bhoma_create_chw_follow.xml" path = r"C:\Users\czue\source\commcare-hq\lib\temp\tempInstance1230017201359950324.xml" # print post_authenticated_file(path, POST_URL, "admin", "admin") print post_file(path, POST_URL)