-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvalidating_files.py
More file actions
29 lines (26 loc) · 857 Bytes
/
validating_files.py
File metadata and controls
29 lines (26 loc) · 857 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
import re
import sys
import os
#######################################################################
# Validation of commandfile
def validate_commandfile(commandfile):
command = []
try:
for line in open(commandfile, 'r'):
isline = re.search("(.*)\n$",line)
if isline:command.append(isline.group(1))
else:command.append(line)
except:
print " Cannot read the provided file "
return command
#######################################################################
# Validation of hostfile
def validate_hostfile(hostfile):
host = []
try:
for line in open(hostfile, 'r'):
hostsearch = re.search("^(\d+\.\d+\.\d+\.\d+).*",line)
if hostsearch:host.append(hostsearch.group(1))
except:
print " Cannot read the provided file "
return host