-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdistribute_web.py
101 lines (62 loc) · 3.15 KB
/
distribute_web.py
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#distribute_web.py
#for putting the real time results to helioforecast.space every hour
#pip install pysftp
import sys
import os
import pysftp
from web_data import *
#(1) ############### copy to helioforecast.space server
print('(1) copy files to helioforecast.space')
print()
sftp=pysftp.Connection(server, username=user, private_key=key,port=port)
sftp.chdir('www-helioforecast/helioforecast/public/sync') #change dir
print(sftp.pwd)
print('copy predstorm_real.png/txt to ',sftp.pwd) #show current dir
sftp.put(path+'predstorm/predstorm_real.png') # upload file to public/ on remote
sftp.put(path+'predstorm/predstorm_real.txt') # upload file to public/ on remote
print('copy aurora maps to ',sftp.pwd) #show current dir
sftp.put(path+'auroramaps/results/aurora_realtime/prob_canada.gif')
sftp.put(path+'auroramaps/results/aurora_realtime/prob_europe.gif')
sftp.put(path+'auroramaps/results/aurora_realtime/prob_global.gif')
sftp.put(path+'auroramaps/results/aurora_realtime/prob_canada_small.gif')
sftp.put(path+'auroramaps/results/aurora_realtime/prob_europe_small.gif')
sftp.put(path+'auroramaps/results/aurora_realtime/prob_global_small.gif')
sftp.put(path+'auroramaps/results/aurora_realtime/prob_canada.mp4')
sftp.put(path+'auroramaps/results/aurora_realtime/prob_europe.mp4')
sftp.put(path+'auroramaps/results/aurora_realtime/prob_global.mp4')
#sftp.get('remote_file') # get a remote file
sftp.close()
print()
print()
#(2) ############### copy to chris dropbox
drop=1
import dropbox
from dropbox.files import WriteMode
if drop > 0:
print('(2) copy files to chris dropbox')
print()
print('upload predstorm_real.png/txt and 3 small aurora gifs to my dropbox ')
db = dropbox.Dropbox(dropkey)
#print('Account infos: ', db.users_get_current_account())
fname = path+'predstorm/predstorm_real.png' # Name einer lokalen Datei
dname = '/predstorm_real.png' # Name der Datei in Dropbox
f = open(fname, 'rb')
response = db.files_upload(f.read(), dname,mode=WriteMode('overwrite'))
fname = path+'predstorm/predstorm_real.txt' # Name einer lokalen Datei
dname = '/predstorm_real.txt' # Name der Datei in Dropbox
f = open(fname, 'rb')
response = db.files_upload(f.read(), dname,mode=WriteMode('overwrite'))
#print('uploaded:', response)
fname = path+'auroramaps/results/aurora_realtime/prob_global_small.gif' # Name einer lokalen Datei
dname = '/prob_global_small.gif' # Name der Datei in Dropbox
f = open(fname, 'rb')
response = db.files_upload(f.read(), dname,mode=WriteMode('overwrite'))
fname = path+'auroramaps/results/aurora_realtime/prob_europe_small.gif' # Name einer lokalen Datei
dname = '/prob_europe_small.gif' # Name der Datei in Dropbox
f = open(fname, 'rb')
response = db.files_upload(f.read(), dname,mode=WriteMode('overwrite'))
fname = path+'auroramaps/results/aurora_realtime/prob_canada_small.gif' # Name einer lokalen Datei
dname = '/prob_canada_small.gif' # Name der Datei in Dropbox
f = open(fname, 'rb')
response = db.files_upload(f.read(), dname,mode=WriteMode('overwrite'))
f.close()