forked from xsank/webssh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
39 lines (26 loc) · 710 Bytes
/
utils.py
File metadata and controls
39 lines (26 loc) · 710 Bytes
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
__author__ = 'xsank'
import re
import sys
_PLATFORM = sys.platform
def check_ip(ip):
pattern = re.compile(
'^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$')
return True if pattern.match(ip) else False
def check_port(port):
if port and port.isdigit():
iport = int(port)
return 0 < iport < 65536
return False
class Platform(object):
@staticmethod
def detail():
return _PLATFORM
@staticmethod
def is_win():
return _PLATFORM.startswith('win')
@staticmethod
def is_linux():
return _PLATFORM.startswith('linux')
@staticmethod
def is_mac():
return _PLATFORM.startswith('darwin')