remove duplicate code
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 3 Jul 2009 11:20:33 +0000 (11:20 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 3 Jul 2009 11:20:33 +0000 (11:20 +0000)
geni/sfa-import-plc.py

index 1823426..9a47932 100755 (executable)
@@ -32,13 +32,24 @@ from geni.util.config import *
 # get PL account settings from config module
 pl_auth = get_pl_auth()
 
+def connect_shell():
+    global pl_auth, shell
+
+    # get PL account settings from config module
+    pl_auth = get_pl_auth()
+
+    # connect to planetlab
+    if "Url" in pl_auth:
+        from geni.util import remoteshell
+        shell = remoteshell.RemoteShell()
+    else:
+        import PLC.Shell
+        shell = PLC.Shell.Shell(globals = globals())
+
+    return shell
+
 # connect to planetlab
-if "Url" in pl_auth:
-    from geni.util import remoteshell
-    shell = remoteshell.RemoteShell()
-else:
-    import PLC.Shell
-    shell = PLC.Shell.Shell(globals = globals())
+shell = connect_shell()
 
 ##
 # Two authorities are specified: the root authority and the level1 authority.
@@ -87,22 +98,6 @@ def process_options():
        name = opt[0]
        val = opt[1]
 
-def connect_shell():
-    global pl_auth, shell
-
-    # get PL account settings from config module
-    pl_auth = get_pl_auth()
-
-    # connect to planetlab
-    if "Url" in pl_auth:
-        from geni.util import remoteshell
-        shell = remoteshell.RemoteShell()
-    else:
-        import PLC.Shell
-        shell = PLC.Shell.Shell(globals = globals())
-
-    return shell
-
 def get_auth_table(auth_name):
     AuthHierarchy = Hierarchy()
     auth_info = AuthHierarchy.get_auth_info(auth_name)