ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Upload.py
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
Content type: text/x-python
File size: 1585 byte(s)
Log Message:
Initial Import

File Contents

# User Rev Content
1 ninoborges 8 """Start regedit. Go to HKEY_CLASSES_ROOT. The key we need is *, probably the very first in a long list.
2     If a subdirectory called Shell already exists, enter it, otherwise create it.
3     (Right-click on the *, choose New Key, type "Shell".)
4    
5     In Shell, create a new key called "Move up" (or whatever you want to call it).
6     Double-click on the value called "Default", then enter "Move up". Create another key here (a sub-key of "Move up"),
7     called "Command". Double-click the "Default" value and enter something like
8    
9    
10     c:\python22\python.exe c:\scripts\moveup.py "%1"
11    
12     That's it. If all went well, all files should now have an option "Move up" in their context menu.
13     Right-click any file to find out."""
14    
15     ## the above was for MoveHere.py but can be used for this program too.
16     #Upload.py
17    
18     import ftplib
19     import os
20     import sys
21     import traceback
22    
23     print "Files:", sys.argv[1:]
24    
25     print "Logging in..."
26     ftp = ftplib.FTP()
27     ftp.connect(host, port)
28     print ftp.getwelcome()
29     try:
30     try:
31     ftp.login(login, password)
32     ftp.cwd(some_directory)
33     # move to the desired upload directory
34     print "Currently in:", ftp.pwd()
35    
36     print "Uploading...",
37     fullname = sys.argv[1]
38     name = os.path.split(fullname)[1]
39     f = open(fullname, "rb")
40     ftp.storbinary('STOR ' + name, f)
41     f.close()
42     print "OK"
43    
44     print "Files:"
45     print ftp.retrlines('LIST')
46     finally:
47     print "Quitting..."
48     ftp.quit()
49     except:
50     traceback.print_exc()
51    
52     raw_input("Press Enter...")