View Single Post
Old 04-29-2011, 11:17 PM   #10
sgtrock
Member
sgtrock can tame squirrels without the assistance of a chair or a whip.sgtrock can tame squirrels without the assistance of a chair or a whip.sgtrock can tame squirrels without the assistance of a chair or a whip.sgtrock can tame squirrels without the assistance of a chair or a whip.sgtrock can tame squirrels without the assistance of a chair or a whip.sgtrock can tame squirrels without the assistance of a chair or a whip.sgtrock can tame squirrels without the assistance of a chair or a whip.sgtrock can tame squirrels without the assistance of a chair or a whip.sgtrock can tame squirrels without the assistance of a chair or a whip.sgtrock can tame squirrels without the assistance of a chair or a whip.sgtrock can tame squirrels without the assistance of a chair or a whip.
 
Posts: 20
Karma: 11190
Join Date: Mar 2011
Device: various
Sorry if I struck a nerve. That wasn't my intent at all.

Seriously, though. Why are you trying to determine network state using Network Manager? Since a good deal of your code seems to be in Python, shouldn't you be using the built-in, OS transparent tool set that comes with it instead? For example, from my copy of "Foundations of Python Network Programming" by John Goerzen:

Code:
#!/usr/bin/env python
# Simple server -Chapter 1 - server.py
import socket

host = ''        # Bind to all interfaces
port = 51423

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

...

etc. ad nauseum
That code is portable across virtually any platform that Python runs on. About the only thing that would have to change is the top line. Similar snippets abound for virtually any language that you care to name.

Take a piece of well intentioned advice from a battle scarred veteran with three plus decades of experience doing network design, admin, and support: You really don't want to write OS specific code if at all possible. It's guaranteed to get you into trouble sooner rather than later. Trust me, you'll be a lot happier if you re-factor your networking code to get rid of any OS discovery/special handling that you may have written.

Still aren't convinced? Ask yourself this: Just how much OS specific code is in the Apache source code? OpenLDAP? PHP? Postgres? Mysql? How much of that OS specific code is geared toward solving networking issues?

Last edited by sgtrock; 04-29-2011 at 11:20 PM.
sgtrock is offline   Reply With Quote