Code Duplication    Length = 23-28 lines in 2 locations

gvmtools/cli.py 1 location

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

gvmtools/pyshell.py 1 location

@@ 248-270 (lines=23) @@
245
        args.timeout = None
246
247
    # Open the right connection. SSH at last for default
248
    if 'socket' in args.connection_type:
249
        socketpath = args.sockpath
250
        if socketpath is None:
251
            socketpath = args.socketpath
252
        else:
253
            print('The --sockpath parameter has been deprecated. Please use '
254
                  '--socketpath instead', file=sys.stderr)
255
256
        connection = UnixSocketConnection(path=socketpath,
257
                                          timeout=args.timeout)
258
    elif 'tls' in args.connection_type:
259
        connection = TLSConnection(
260
            timeout=args.timeout,
261
            hostname=args.hostname,
262
            port=args.port,
263
            certfile=args.certfile,
264
            keyfile=args.keyfile,
265
            cafile=args.cafile,
266
        )
267
    else:
268
        connection = SSHConnection(hostname=args.hostname, port=args.port,
269
                                   timeout=args.timeout, username=args.ssh_user,
270
                                   password='')
271
272
    transform = EtreeCheckCommandTransform()
273