Code Duplication    Length = 23-28 lines in 2 locations

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:

gmp/clients/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