Sep-22-2017, 11:31 AM
What I was planning to do is to have a multiple JSON objects, for example:
1. Use the profiles, between 0 - x
2. concurrently it with my code
3. When finished - exit
A more visual representation:
![[Image: 5nwbX.png]](https://i.stack.imgur.com/5nwbX.png)
*What I have done so far*
I can read one JSON object at this moment with this code:
Which gives me this output: If the first Json profile and it cant be a added another profile inside the Json else the code will not recoinze it.
An example for code that can be made out of this
*What I expect to happened*...
What I expect to happened or want to make it to work is that with those information inside the Json file. To take those information --> Load it into the code (Below) - Make each json object profile to work concurrently with each THREAD and when everybody is done then exit pretty much. No mix between profile 1 and other or so. Every profile run for itself and execute the same way.
**CODE**
So I assume we need to make them running concurrently by multiprocess for every profile to run on their own thread without iterat between other profiles?
{ "Profiles": { "profile_0": { "Url": "Myownwebsite.se", "My-Note": "Helloworld", "Email": "[email protected]" "PersonNumber": "1234543", "postal_code": "54123", "given_name": "World", "Last_name": "Hellow", "street_address": "helloworld 123", "city": "Stockholm", "country": "Sweden", "phone": "123456789", "Color": "Red", "house_number": "123", "year": "2017" }, "profile_1": { "Url": "Myasdwfaesite.se", "My-Note": "aasfase", "Email": "[email protected]" "PersonNumber": "5634543", "postal_code": "123445", "given_name": "Balling", "Last_name": "Calling", "street_address": "qwertr 123", "city": "London", "country": "UK", "phone": "65412331", "Color": "Blue", "house_number": "321", "year": "2018" } #Profile_2 etc etc } }and my plan is to make the json profile/objects to work concurrently through my code.
1. Use the profiles, between 0 - x
2. concurrently it with my code
3. When finished - exit
A more visual representation:
![[Image: 5nwbX.png]](https://i.stack.imgur.com/5nwbX.png)
*What I have done so far*
I can read one JSON object at this moment with this code:
with open('profileMulti.json', 'r', encoding='UTF-8') as json_data: config = json.load(json_data)
Which gives me this output: If the first Json profile and it cant be a added another profile inside the Json else the code will not recoinze it.
An example for code that can be made out of this
"Url": "Myownwebsite.se", "My-Note": "Helloworld", "Email": "[email protected]" "PersonNumber": "1234543", "postal_code": "54123", "given_name": "World", "Last_name": "Hellow", "street_address": "helloworld 123", "city": "Stockholm", "country": "Sweden", "phone": "123456789",^ This is from my code on below.
*What I expect to happened*...
What I expect to happened or want to make it to work is that with those information inside the Json file. To take those information --> Load it into the code (Below) - Make each json object profile to work concurrently with each THREAD and when everybody is done then exit pretty much. No mix between profile 1 and other or so. Every profile run for itself and execute the same way.
**CODE**
with open('profileMulti.json', 'r', encoding='UTF-8') as json_data: config = json.load(json_data) NameUrl = config["Url"] myNote = config["My-Note"] def checkoutNames(NameUrl, nameID): #Request & other codes - Removed to recude the code #...... #...... headers = { 'Referer': '', 'Content-Type': '' } payload = { "shared": { "challenge": { "email": config["Email"], "PersonNumber": config["PersonNumber"], "postal_code": config["ZipCode"], "given_name": config["Name"], "Last_name": config["LastName"], "street_address": config["Address"], "postal_code": config["ZipCode"], "city": config["City"], "country": config["Country"], "email": config["Email"], "phone": config["Phone"], } def checkoutNotes(NamesUrl, NamesPost): #Request & other codes - Removed to recude the code #...... #...... headers = { 'Accept': 'application/json, text/javascript, /; q=0.01', 'Accept-Language': 'en-US,en;q=0.5', 'Accept-Encoding': 'gzip, deflate, br', 'Referer': NameUrl, 'Connection': 'keep-alive' } payloadInfo = { "Information": { "Color": config["Color"], "house_number": config["houseNumber"], "year": config["Year"] } } def wipe(): os.system('cls' if os.name == 'nt' else 'clear') def main(): time.sleep(1) FindName(myNote) if _name_ == '_main_': try: { main() } except KeyboardInterrupt: wipe()So easy to say. There is functions in the code such as from the beginning,
checkoutNames
and checkoutNotes
. Basically we have different profiles. Make each profile to work concurrently with each thread for itself. Execute the code by itself and add those information from Json to the code I have entered here and vioala. That's pretty much what I dream at this moment to get it to work. So I assume we need to make them running concurrently by multiprocess for every profile to run on their own thread without iterat between other profiles?