-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
56 lines (49 loc) · 1.18 KB
/
main.py
File metadata and controls
56 lines (49 loc) · 1.18 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
56
from exception import *
from clientlib import *
from shell import *
import sys, getopt
import settings
def main(argv):
if not argv:
usage()
sys.exit()
hostname=argv[0]
port=21
username='anonymous' #Default username
password='anonymous@' #Default Password
try:
opts,args = getopt.getopt(argv[1:],"hp:u:P")
except getopt.GetoptError:
''' Invalid arguments'''
raise getopt.GetoptError('Invalid Paramaters')
else:
for opt,arg in opts:
if opt == '-h':
'''Display help'''
pass
elif opt == '-p':
'''Custom port number provided'''
try:
port = int(arg)
except Exception,e:
'''Invalid port number error'''
raise InvalidPortNumberError('Please enter a valid port number')
sys.exit()
elif opt == '-u':
username = arg
password=''
elif opt == '-P':
password = arg
try:
sh = Shell(CLIENT(hostname,port,username,password))
except Exception,e:
print e
def usage():
print 'Usage:'
print 'pyftp <hostname> -p <portnum> -u <username> -P <password>'
print 'optional parameters:'
print '-p: Default set to 21'
print '-u: Default is anonymous'
print '-P: Default is anonymous@'
if(__name__=='__main__'):
main(sys.argv[1:])