Code Duplication    Length = 23-28 lines in 2 locations

gmp/clients/pyshell.py 1 location

@@ 216-238 (lines=23) @@
213
        args.timeout = None
214
215
    # Open the right connection. SSH at last for default
216
    if 'socket' in args.connection_type:
217
        socketpath = args.sockpath
218
        if socketpath is None:
219
            socketpath = args.socketpath
220
        else:
221
            print('The --sockpath parameter has been deprecated. Please use '
222
                  '--socketpath instead', file=sys.stderr)
223
224
        connection = UnixSocketConnection(path=socketpath,
225
                                          timeout=args.timeout)
226
    elif 'tls' in args.connection_type:
227
        connection = TLSConnection(
228
            timeout=args.timeout,
229
            hostname=args.hostname,
230
            port=args.port,
231
            certfile=args.certfile,
232
            keyfile=args.keyfile,
233
            cafile=args.cafile,
234
        )
235
    else:
236
        connection = SSHConnection(hostname=args.hostname, port=args.port,
237
                                   timeout=args.timeout, username=args.ssh_user,
238
                                   password='')
239
240
    gmp = Gmp(connection, transform=EtreeCheckCommandTransform())
241

gmp/clients/cli.py 1 location

@@ 206-233 (lines=28) @@
203
                                            args.gmp_username + ': ')
204
205
    # Open the right connection. SSH at last for default
206
    if 'socket' in args.connection_type:
207
        socketpath = args.sockpath
208
        if socketpath is None:
209
            socketpath = args.socketpath
210
        else:
211
            print('The --sockpath parameter has been deprecated. Please use '
212
                  '--socketpath instead', file=sys.stderr)
213
214
        connection = UnixSocketConnection(
215
            timeout=args.timeout,
216
            path=socketpath
217
        )
218
    elif 'tls' in args.connection_type:
219
        connection = TLSConnection(
220
            timeout=args.timeout,
221
            hostname=args.hostname,
222
            port=args.port,
223
            certfile=args.certfile,
224
            keyfile=args.keyfile,
225
            cafile=args.cafile,
226
        )
227
    else:
228
        connection = SSHConnection(
229
            timeout=args.timeout,
230
            hostname=args.hostname,
231
            port=args.port,
232
            username=args.ssh_user,
233
            password=args.ssh_password
234
        )
235
236
    if args.raw: