More work on qwknet
This commit is contained in:
parent
1d649c8db5
commit
d483d82ca3
@ -1,5 +1,8 @@
|
||||
[Main]
|
||||
Host = VERT
|
||||
Ftp server = vert.synchro.net
|
||||
Ftp user = username
|
||||
Ftp Password = password
|
||||
Message Path = /home/andrew/MagickaBBS/msgs/dovenet
|
||||
Inbound = /home/andrew/MagickaBBS/qwk/in
|
||||
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,36 +344,40 @@ int main(int argc, char **argv) {
|
||||
fprintf(stderr, "Exporting from base %d... %d exported\n", msgbases[i]->baseno, msgcount);
|
||||
}
|
||||
|
||||
snprintf(archive, PATH_MAX, "%s/%s.REP", outbound_path, hostid);
|
||||
if (qwkidx > 0) {
|
||||
|
||||
char *b = buffer;
|
||||
size_t blen = sizeof buffer;
|
||||
for (const char *p = pack_cmd; *p != '\0' && blen >= 1; ++p) {
|
||||
if (*p != '*') {
|
||||
*b++ = *p;
|
||||
--blen;
|
||||
continue;
|
||||
}
|
||||
p++;
|
||||
size_t alen = 0;
|
||||
if (*p == 'a') {
|
||||
strncpy(b, archive, blen);
|
||||
alen = strlen(archive);
|
||||
} else if (*p == 'f') {
|
||||
snprintf(b, blen, "%s/%s.MSG", temp_dir, hostid);
|
||||
alen = strlen(b);
|
||||
} else if (*p == '*') {
|
||||
*b++ = '*';
|
||||
alen = 1;
|
||||
}
|
||||
b += alen;
|
||||
blen -= alen;
|
||||
}
|
||||
*b = '\0';
|
||||
snprintf(archive, PATH_MAX, "%s/%s.REP", outbound_path, hostid);
|
||||
|
||||
ret = system(buffer);
|
||||
if (ret == -1 || ret >> 8 == 127) {
|
||||
return -1;
|
||||
char *b = buffer;
|
||||
size_t blen = sizeof buffer;
|
||||
for (const char *p = pack_cmd; *p != '\0' && blen >= 1; ++p) {
|
||||
if (*p != '*') {
|
||||
*b++ = *p;
|
||||
--blen;
|
||||
continue;
|
||||
}
|
||||
p++;
|
||||
size_t alen = 0;
|
||||
if (*p == 'a') {
|
||||
strncpy(b, archive, blen);
|
||||
alen = strlen(archive);
|
||||
} else if (*p == 'f') {
|
||||
snprintf(b, blen, "%s/%s.MSG", temp_dir, hostid);
|
||||
alen = strlen(b);
|
||||
} else if (*p == '*') {
|
||||
*b++ = '*';
|
||||
alen = 1;
|
||||
}
|
||||
b += alen;
|
||||
blen -= alen;
|
||||
}
|
||||
*b = '\0';
|
||||
|
||||
ret = system(buffer);
|
||||
if (ret == -1 || ret >> 8 == 127) {
|
||||
fprintf(stderr, "Failed to run archiver!\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
recursive_delete(temp_dir);
|
||||
}
|
Reference in New Issue
Block a user