More work on qwknet
This commit is contained in:
parent
1d649c8db5
commit
d483d82ca3
@ -1,5 +1,8 @@
|
|||||||
[Main]
|
[Main]
|
||||||
Host = VERT
|
Host = VERT
|
||||||
|
Ftp server = vert.synchro.net
|
||||||
|
Ftp user = username
|
||||||
|
Ftp Password = password
|
||||||
Message Path = /home/andrew/MagickaBBS/msgs/dovenet
|
Message Path = /home/andrew/MagickaBBS/msgs/dovenet
|
||||||
Inbound = /home/andrew/MagickaBBS/qwk/in
|
Inbound = /home/andrew/MagickaBBS/qwk/in
|
||||||
Outbound = /home/andrew/MagickaBBS/qwk/out
|
Outbound = /home/andrew/MagickaBBS/qwk/out
|
||||||
|
50
utils/qwknet/qwknetftpc.py
Normal file
50
utils/qwknet/qwknetftpc.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
from ftplib import FTP
|
||||||
|
import configparser
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def dostuff(config_file):
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read(config_file)
|
||||||
|
host = config.get("Main", "Ftp Server")
|
||||||
|
username = config.get("Main", "Ftp User")
|
||||||
|
password = config.get("Main", "Ftp Password")
|
||||||
|
|
||||||
|
ftp = FTP(host)
|
||||||
|
ftp.login(username, password)
|
||||||
|
|
||||||
|
repfile = config.get("Main", "Outbound") + "/" + config.get("Main", "Host") + ".REP"
|
||||||
|
|
||||||
|
exists = os.path.isfile(repfile)
|
||||||
|
|
||||||
|
if exists:
|
||||||
|
file = open(repfile, "rb")
|
||||||
|
ftp.storbinary("STOR " + config.get("Main", "Host") + ".REP", file)
|
||||||
|
file.close()
|
||||||
|
os.remove(repfile)
|
||||||
|
print("SENT: " + config.get("Main", "Host") + ".REP")
|
||||||
|
|
||||||
|
qwkfile = config.get("Main", "Inbound") + "/" + config.get("Main", "Host") + ".QWK"
|
||||||
|
with open(qwkfile, 'wb') as file:
|
||||||
|
def callback(data):
|
||||||
|
file.write(data)
|
||||||
|
|
||||||
|
try:
|
||||||
|
ftp.retrbinary("RETR " + config.get("Main", "Host") + ".QWK", callback)
|
||||||
|
file.close()
|
||||||
|
print("RETREIVED: " + config.get("Main", "Host") + ".QWK")
|
||||||
|
except ftplib.error_perm:
|
||||||
|
file.close()
|
||||||
|
os.remove(qwkfile)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print("Usage python qwknetftpc.py config.ini")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
server = dostuff(sys.argv[1])
|
@ -344,6 +344,8 @@ int main(int argc, char **argv) {
|
|||||||
fprintf(stderr, "Exporting from base %d... %d exported\n", msgbases[i]->baseno, msgcount);
|
fprintf(stderr, "Exporting from base %d... %d exported\n", msgbases[i]->baseno, msgcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qwkidx > 0) {
|
||||||
|
|
||||||
snprintf(archive, PATH_MAX, "%s/%s.REP", outbound_path, hostid);
|
snprintf(archive, PATH_MAX, "%s/%s.REP", outbound_path, hostid);
|
||||||
|
|
||||||
char *b = buffer;
|
char *b = buffer;
|
||||||
@ -373,7 +375,9 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
ret = system(buffer);
|
ret = system(buffer);
|
||||||
if (ret == -1 || ret >> 8 == 127) {
|
if (ret == -1 || ret >> 8 == 127) {
|
||||||
|
fprintf(stderr, "Failed to run archiver!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
recursive_delete(temp_dir);
|
recursive_delete(temp_dir);
|
||||||
}
|
}
|
Reference in New Issue
Block a user