Sep-22-2017, 11:31 AM
What I was planning to do is to have a multiple JSON objects, for example:
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:
)
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
^ 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**
So easy to say. There is functions in the code such as from the beginning,
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?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
{ "Profiles" : { "profile_0" : { "Url" : "Myownwebsite.se" , "My-Note" : "Helloworld" , "Email" : "Stackoverflow@gmail.com" "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" : "fasfsef@gmail.com" "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 } } |
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:
1 2 |
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
1 2 3 4 5 6 7 8 9 10 11 |
"Url" : "Myownwebsite.se" , "My-Note" : "Helloworld" , "Email" : "Stackoverflow@gmail.com" "PersonNumber" : "1234543" , "postal_code" : "54123" , "given_name" : "World" , "Last_name" : "Hellow" , "street_address" : "helloworld 123" , "city" : "Stockholm" , "country" : "Sweden" , "phone" : "123456789" , |
*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**
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
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() |
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?