diff options
author | Alvaro Neira Ayuso <aneira@soleta.eu> | 2019-12-12 11:50:46 +0100 |
---|---|---|
committer | Alvaro Neira Ayuso <alvaroneay@gmail.com> | 2020-01-19 19:50:44 +0100 |
commit | 29fe301ec82a657ee889411ad032af9909ceb6a4 (patch) | |
tree | 2979c65a5a0fb4cfb9c8424f2e905b595977cbe2 /main.py | |
parent | e3d707cfb3dad78388663339af9412e0697b358c (diff) |
Create new ogClient
This commit init the new ogClient. The new ogClient has support for configuring
and for connecting with the ogAdminServer.
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -0,0 +1,39 @@ +from src.ogClient import *
+from src.ogConfig import *
+
+CONNECTING = 0
+RECEIVING = 1
+
+def main():
+ ogconfig = ogConfig()
+ if (not ogconfig.parserFile('cfg/ogagent.cfg')):
+ print 'Error: Parsing configuration file'
+ return 0
+
+ ip = ogconfig.getValueSection('opengnsys', 'ip')
+ port = ogconfig.getValueSection('opengnsys', 'port')
+
+ client = ogClient(ip, int(port))
+ client.connect()
+
+ while 1:
+ sock = client.get_socket()
+ state = client.get_state()
+
+ if state == CONNECTING:
+ readset = [ sock ]
+ writeset = [ sock ]
+ else:
+ readset = [ sock ]
+ writeset = [ ]
+
+ readable, writable, exception = select.select(readset, writeset, [ ])
+ if state == CONNECTING and sock in writable:
+ client.connect2()
+ elif state == RECEIVING and sock in readable:
+ client.receive()
+ else:
+ print "bad state" + str(state)
+
+if __name__ == "__main__":
+ main()
|