-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupload2.rb
72 lines (62 loc) · 1.63 KB
/
upload2.rb
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/mnt/sd/deploy/usr/bin/ruby
# -*- coding: utf-8 -*-
require 'net/ftp'
require 'net/http'
require 'uri'
require 'exifr'
include EXIFR
# ------------------------------
# user configuration
# ------------------------------
#DONE_FILE = "/mnt/sd/FLU/alreadydone.txt"
DONE_FILE = "/tmp/allnewfiles3"
OUT_FILE = "/tmp/outfile"
FINAL_OUT_FILE = "/mnt/mtd/"
FTP_SERVER = "jjrosent.zrg.cc"
FTP_USER = "zrg"
FTP_PASSWORD = "nAFmkvvbQvMq9GapSn"
FTP_PATH = "/data/uploads_t/zrg/flu"
#LOCAL_PATH = "/mnt/sd/DCIM/"
# ------------------------------
# main
# ------------------------------
def test_thumbnail
count = 0
all_test_jpegs.each do |fname|
jpeg = JPEG.new(fname)
unless jpeg.thumbnail.nil?
assert_nothing_raised 'thumbnail not a JPEG' do
JPEG.new(StringIO.new(jpeg.thumbnail))
end
count += 1
end
end
assert count > 0, 'no thumbnails found'
end
if !File.exists?(DONE_FILE)
exit
else
begin
alreadydone = File.read(DONE_FILE).split("\n")
# workon = Dir.entries(LOCAL_PATH).delete_if { |x| a.include?(x) || x.include?(".") }
workon = alreadydone
# fulllist = Dir[LOCAL_PATH].each { |file| }
ftp = Net::FTP.open(FTP_SERVER, FTP_USER, FTP_PASSWORD)
ftp.chdir(FTP_PATH)
workon.each do |fname|
if File.exists?(fname)
begin
ftp.putbinaryfile(fname, File.basename(fname))
print "#{File.basename(fname)} uploaded."
File.open(OUT_FILE, "a") { |f| f.write(File.basename(fname) + "\n")}
rescue
print "Error while ftp put: #{$!}"
exit
end
end
print "All uploads done."
end
rescue
print "Error while processing: #{$!}"
end
end