Software Development and Programming Careers (Official Discussion Thread)

Joined
Apr 3, 2014
Messages
71,910
Reputation
17,063
Daps
305,930
What problems did you have?




Docker container wouldn't start. The backend started but couldn't get the frontend going. Turns out it was a difference in mongodb commands between systems. And then on top of that, I had the Ubuntu version of mongodb, instead of the actual version. And it was creating a conflict between mongodb and mongorestore (which I didn't realize are 2 different things now). So because I had the ubuntu version, when I installed mongorestore the first time, it corrupted my mongo installation. So I had to purge it from my system and install the actual official version of it. Once I did that, I was finally able to get my mongo going. From that, the team lead was able to give me a command with the proper arguments to get everything else going.





tldr
It was basically a versioning issue.
 
Joined
Apr 3, 2014
Messages
71,910
Reputation
17,063
Daps
305,930
:ohhh: so its me and this other dude working together and when I first met him, I thought he was a much better programmer than me cause he was doing it longer and already knew about the backend and all of that.

But over the last couple days, he's been coming to me asking for help for things that he can't figure out.

What does it mean? :ohhh: am I better than I thought I was?
 

Obreh Winfrey

Truly Brehthtaking
Supporter
Joined
Nov 18, 2016
Messages
20,851
Reputation
25,252
Daps
131,926
:ohhh: so its me and this other dude working together and when I first met him, I thought he was a much better programmer than me cause he was doing it longer and already knew about the backend and all of that.

But over the last couple days, he's been coming to me asking for help for things that he can't figure out.

What does it mean? :ohhh: am I better than I thought I was?
The average employee anywhere is not particularly good at what they do. Doesn't matter the industry. If you're even moderately competent then you're already a step ahead. shyt, these people are still struggling to figure out how to screen share half the time. So yes, you're better than you thought you were, and as long as you have even the slightest ability to troubleshoot or seek answers to questions on your own, you'll be head and shoulders above 90% of your peers.
 

Sonny Bonds

Superstar
Supporter
Joined
Apr 24, 2014
Messages
4,611
Reputation
916
Daps
13,207
In my code, the print(f"User: {device['user']}") line gives me:

User: {'email': 'sonnyb@company.com', 'name': 'Sonny Bonds', 'id': 323, 'is_archived': Null}

How do I print out just the name value? I feel stupid and I feel like I always run into this issue with APIs.

import requests
import json
url = "https://subdomain.clients.us-1.kandji.io/api/v1/devices"
payload={}
headers = {
'Authorization': 'Bearer APIKEYGOESHERE'
}
response = requests.request("GET", url, headers=headers, data=payload)
data = response.json()
for device in data:
print("------------------------------------------------------------")
print(f"Device: {device['device_name']}")
print(f"Model: {device['model']}")
print(f"Serial Number: {device['serial_number']}")
print(f"Platform: {device['platform']}")
print(f"OS Version: {device['os_version']}")
print(f"Last Check In: {device['last_check_in']}")
print(f"User: {device['user']}")
print(f"Blueprint: {device['blueprint_name']}")
print(f"Last Check In: {device['last_check_in']}")
print("------------------------------------------------------------")
 

Obreh Winfrey

Truly Brehthtaking
Supporter
Joined
Nov 18, 2016
Messages
20,851
Reputation
25,252
Daps
131,926
That's what I thought, but when I tried it, I got:
TypeError: string indices must be integers, not 'str'
Ah I see. device['user'] is a string and not a JSON object. I don't remember the python library but maybe doing a user = json.loads (device['user']). That should turn that string into a dict, basically, then you should be able to access the individual fields.
 

Regular Developer

Supporter
Joined
Jun 2, 2012
Messages
8,080
Reputation
1,796
Daps
22,824
Reppin
NJ
:ohhh: so its me and this other dude working together and when I first met him, I thought he was a much better programmer than me cause he was doing it longer and already knew about the backend and all of that.

But over the last couple days, he's been coming to me asking for help for things that he can't figure out.

What does it mean? :ohhh: am I better than I thought I was?
My manager sometimes asks me to look over his code or do a mini code review with him. I don't think much of these things. But if it helps you be more confident in your coding ability, then hopefully thats the take away. Just stay humble with it, cause as soon as you think your the goat, a situation pops up to make you feel stupid...or least for me, lol
 

Regular Developer

Supporter
Joined
Jun 2, 2012
Messages
8,080
Reputation
1,796
Daps
22,824
Reppin
NJ
Ah I see. device['user'] is a string and not a JSON object. I don't remember the python library but maybe doing a user = json.loads (device['user']). That should turn that string into a dict, basically, then you should be able to access the individual fields.
Yup, good call:

 

Sonny Bonds

Superstar
Supporter
Joined
Apr 24, 2014
Messages
4,611
Reputation
916
Daps
13,207
Ah I see. device['user'] is a string and not a JSON object. I don't remember the python library but maybe doing a user = json.loads (device['user']). That should turn that string into a dict, basically, then you should be able to access the individual fields.
Thanks.

I'm going to fandangle a way to use Python in every project at work. I'm not stopping this time.
 
Joined
Apr 3, 2014
Messages
71,910
Reputation
17,063
Daps
305,930
My manager sometimes asks me to look over his code or do a mini code review with him. I don't think much of these things. But if it helps you be more confident in your coding ability, then hopefully thats the take away. Just stay humble with it, cause as soon as you think your the goat, a situation pops up to make you feel stupid...or least for me, lol




I believe you. I wasn't saying it as a "im finally here :blessed:" moment. Just as a "i thought I was absolutely trash as a programmer, but maybe not:leon:" moment.
 

Sonny Bonds

Superstar
Supporter
Joined
Apr 24, 2014
Messages
4,611
Reputation
916
Daps
13,207
Ah I see. device['user'] is a string and not a JSON object. I don't remember the python library but maybe doing a user = json.loads (device['user']). That should turn that string into a dict, basically, then you should be able to access the individual fields.

Yup, good call:


if (type(user)) == dict:
print(user['name'])
else:
continue
 
Top