forked from VenkateshDoijode/selenium_with_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
55 lines (45 loc) · 1.4 KB
/
Copy pathtest.py
File metadata and controls
55 lines (45 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'''
Created on May 30, 2018
@author: venkateshwara.d
'''
import random, string
class Test():
def getAlphaNumeric(self, length, type='letters'):
"""
Get random string of characters
Required Parameters:
length: Length of string, number of characters string should have
Optional Parameters:
type: Type of characters string should have. Default is letters
Provide lower/upper/digits for different types
Returns:
None
"""
alpha_num = ''
if type == 'lower':
case = string.ascii_lowercase
elif type == 'upper':
case = string.ascii_uppercase
elif type == 'digits':
case = string.digits
elif type == 'mix':
case = string.ascii_letters + string.digits
else:
case = string.ascii_letters
return alpha_num.join(random.choice(case) for i in range(length))
def getValidPort(self, count=4):
"""
Get a valid port number
Required Parameters:
None
Optional Parameters:
count: Number of digits in a port. Default is 4.
Returns:
None
"""
port = self.getAlphaNumeric(count, 'digits')
if int(port) > 65535:
print("65535")
return self.getAlphaNumeric(count, 'digits')
t = Test()
t.getValidPort(count=6)