DWD Wetter, 727272 ulbrichf d

Moderator: DF3OE

Antworten
Benutzeravatar

Topic author
ulbrichf
Rank 12
Rank 12
Beiträge: 646
Registriert: Sa 4. Jun 2016, 20:54
Wohnort: Grefrath, D
Hauptanschluß: 992158 ulbrichf d

DWD Wetter, 727272 ulbrichf d

#1

Beitrag von ulbrichf » Mo 3. Okt 2016, 17:31

Hallo zusammen,
da mein Infotext auf der google group etwas unübersichtlich wird, möchte ich das Forum nutzen, um meine Zwischenstände zum Thema
"Wettermeldungen vm DWD via iTELEX" zu posten. Als Nichtprogrammieren bin ich dabei, unter PYTHON Teilprogramme zu schreiben,
die automatisch auf meinem RASPBERRY PI laufen sollen. Die Testläufe fanden auf einem Windows Lapto statt.
Seit gestern wurden der Programmcode portiert und automatiert über die CROMNTAB gestartet. Scheint bisher zu laufen.
Ärger machen noch Monatsübergänge. Der Programmcode muß nun noch aufgeräumt und das Menükonzept überarbeitet werden.

Gruß
Frank
Folgende Benutzer bedankten sich beim Autor ulbrichf für den Beitrag (Insgesamt 3):
AlexKlausMinifranz
NNNN

Gruß
Frank Ulbrich / DO2FU / 92158 ulbrichf d / TeKaDe FS220z (online) / T68D (online) / T1000S (online) / iTELEX FW 825 / TW39PLUS FW 330 / seriell speicher version FW 346 / ED1000 FW 330

Benutzeravatar

Alex
Administrator
Administrator
Beiträge: 883
Registriert: Mi 25. Mai 2016, 11:04
Wohnort: Dresden
Hauptanschluß: 411763 lhxt d
Kontaktdaten:

Re: DWD Wetter, 727272 ulbrichf d

#2

Beitrag von Alex » Mo 3. Okt 2016, 17:35

ulbrichf hat geschrieben:da mein Infotext auf der google group etwas unübersichtlich wird, möchte ich das Forum nutzen
Willkommen auf der guten Seite der Macht, mein Sohn.

Ausserdem: Vielen Dank für Deine Arbeit an dem Projekt, freue mich, wenn irgendwann mal alle Bundesländer dort ihre eigene Vorhersage abrufen können. Bekommst ein "Sticky" dafür ;)
NEUE HAUPTRUFNUMMER [411763] SEIT 1.10.18
Fernschreibstelle Dresden
411763 lhxt d (Siemens T1000S/MD) online
4185663 como d (Siemens T1200SD) offline
133176 aanow su (Siemens PT80-5) online
765940 =alex d (Minitelex) online


Helge

Re: DWD Wetter, 727272 ulbrichf d

#3

Beitrag von Helge » Mo 3. Okt 2016, 17:37

Hallo Farnk,
google group
Ich wusste gar nicht, dass es eine gibt :?

Grüsse

Helge

Benutzeravatar

Alex
Administrator
Administrator
Beiträge: 883
Registriert: Mi 25. Mai 2016, 11:04
Wohnort: Dresden
Hauptanschluß: 411763 lhxt d
Kontaktdaten:

Re: DWD Wetter, 727272 ulbrichf d

#4

Beitrag von Alex » Mo 3. Okt 2016, 17:44

Naja, die Mailingliste, das schwerfällige Ungetüm aus den 80er Jahren... der T-Rex, dessen Ärmchen zu kurz sind...
NEUE HAUPTRUFNUMMER [411763] SEIT 1.10.18
Fernschreibstelle Dresden
411763 lhxt d (Siemens T1000S/MD) online
4185663 como d (Siemens T1200SD) offline
133176 aanow su (Siemens PT80-5) online
765940 =alex d (Minitelex) online

Benutzeravatar

Topic author
ulbrichf
Rank 12
Rank 12
Beiträge: 646
Registriert: Sa 4. Jun 2016, 20:54
Wohnort: Grefrath, D
Hauptanschluß: 992158 ulbrichf d

Re: DWD Wetter, 727272 ulbrichf d

#5

Beitrag von ulbrichf » Mo 3. Okt 2016, 18:56

https://groups.google.com/forum/#!forum/telex

a) 0tlx_dwdserver077.py : Der Socks Server
b) 1tlx_ftp_down_sms.py : Herunterladen von SMS Warnmeldungen nach filedownload
c) 2tlx_ftp_down_forecast.py : Download Forecast und Warnlagen
d) 3tlx_baud_conv-warn-py : Konvertierung Warnmeldungen nach Baud und Ablage unter CONVERTED
e) 4tlx_baud_conv-forecast.py : Konvertierung 10 Tagevorhersage und Wetterprosa

Code: Alles auswählen

#!/usr/bin/env python
#***********************************************************
# Programm : 0tlx_dwdserver077.py   (BETA)
# Autor    : Frank Ulbrich
# Datum    : 02.10.2016
#***********************************************************
#LINKS / QUELLE
#http://www.binarytides.com/python-socket-server-code-example/
#http://stackoverflow.com/questions/25048259/how-do-i-correctly-process-input-in-this-python-local-chatting-server
#***********************************************************
# python 2.7
#***********************************************************
# Socketserver welcher menugesteuert Textdateien anbietet.
# iTELEX : 727272

import socket
import sys
import textwrap
import datetime
import time

from thread import *
 
HOST = ''   # Symbolic name meaning all available interfaces
PORT = 133   # Arbitrary non-privileged port

global sessioncount
sessioncount = 0
now = datetime.datetime.now()
version = "v0.7.7 RASPBERRY PORT 133"
prgname = "tlx_dwdserver "
filepath = "converted/"               # Linux

print(prgname + version + '\r\n')
print (now.strftime("%Y-%m-%d %H:%M") + '\r\n')

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print ('Socket created')
print ("Host ip : " + HOST)
print ("Port    : " + str(PORT))
#print "Current year: %d" % now.year
#print "Current month: %d" % now.month
#print "Current day: %d" % now.day
#Bind socket to local host and port

try:
    s.bind((HOST, PORT))
except socket.error as msg:
    print 'Bind failed. Error Code : ' + str(msg[0]) + ' Message ' + msg[1]
    sys.exit()
     
print 'Socket bind complete'
 
#Start listening on socket

s.listen(5)
#s.settimeout(10)
print 'Socket now listening'

#*******************************************************************************
 
#Function for handling connections. This will be used to create threads. Input is a cmplete line, not a single character.
def clientThreadLine (conn):
    sessioncount = 0
    conn.settimeout(300)      # Setzen, wann die Session benedet werden soll in Sekunden
    geberfile = conn.makefile("r",1)
    try:
        sessioncount = sessioncount +1
        print('SITZUNG : ' + str(sessioncount) + '\r\n')
        conn.send('727272 ULBRICHF D\r\n' )
        conn.send('@')
        geber = geberfile.readline(16)
        print('Kennungsgeber : ' + geber)
        #time.sleep(1)
        conn.send('\r\n')
        conn.send(prgname + version + '\r\n')
        conn.send(now.strftime("%Y-%m-%d %H:%M") + '\r\n')
        conn.send('--------------------------------------------\r\n' )
        conn.send('WETTER DATEN            X = ENDE\r\n' )
        conn.send('A = WARNMELDUNG BAY     B = WARNMELDUNG NRW\r\n' )
        conn.send('C = WARNMELDUNG NDS/BRE D = WETTER PROSA\r\n' )
        conn.send('E = WARNMELDUNG MVP\r\n' )
        conn.send('F = 10 DE TAGE VORHERSAGE\r\n' )
        conn.send('--------------------------------------------\r\n' )
        conn.send('BUCHSTABEN EINGEBEN UND DANN ZEILENVORSCHUB\r\n' )
        conn.send('\r\n' )
        #conn.send('@')
        # makefile creates a file-like object with a readline method)
        # from a socket. "r" means read-only mode, and 1 means line-buffered
        #
        connfile = conn.makefile("r", 1)
        try:
            while True:
                # readline will block until a newline '\n' is encountered
                # or the stream is closed
                data = connfile.readline(16)
                # the readline method includes the trailing newlines,
                # so we want to strip them
                data = data.rstrip("\r\n")         # CRLF enfernen
                # reply = 'AUSWAHL : ' + data
                reply = (data + ' GEWAEHLT\r\n')
                conn.send(reply)
                print(reply)
                if data == 'a':
                       print ('*Datei Warnmeldung BAY*') 
                       #myfile = open(".\\converted\\VHDL30_DWMG.txt",'r')
                       myfile = open(filepath + "VHDL30_DWMG.txt",'r')
                       for line in myfile :
                        #line = line + '\r'         # ein CR anhaengen => LFCR
                        line = line.replace('\n', '\r\n') # LF gegen CRLF tauschen
                        conn.send(line)
                       myfile.close()
                if data == 'b':
                       print ('*Datei Warnmeldung NRW*') 
                       #myfile = open(".\\converted\\VHDL30_DWEH.txt",'r')
                       myfile = open(filepath + "VHDL30_DWEH.txt",'r')
                       for line in myfile :
                        #line = line + '\r'         # ein CR anhaengen => LFCR
                        line = line.replace('\n', '\r\n') # LF gegen CRLF tauschen
                        conn.send(line)
                       myfile.close()
                if data == 'c':
                       print ('*Datei Warnmeldung NDS*') 
                       #myfile = open(".\\converted\\VHDL30_DWHG.txt",'r')
                       myfile = open(filepath + "VHDL30_DWHG.txt",'r')
                       for line in myfile :
                        #line = line + '\r'         # ein CR anhaengen => LFCR
                        line = line.replace('\n', '\r\n') # LF gegen CRLF tauschen
                        conn.send(line)
                       myfile.close()
                if data == 'd':
                       print ('*Datei Wetterprosa*') 
                       #myfile = open(".\\converted\\FPDL13_DWMZ.txt",'r')
                       myfile = open(filepath + "FPDL13_DWMZ.txt",'r')
                       for line in myfile :
                        #line = line + '\r'
                        line = line.replace('\n', '\r\n') # LF gegen CRLF tauschen
                        conn.send(line)
                       myfile.close()
                if data == 'e':
                       print ('*Datei Warnmelding POM*') 
                       #myfile = open(".\\converted\\VHDL30_DWPH.txt",'r')
                       myfile = open(filepath + "VHDL30_DWPH.txt",'r')
                       for line in myfile :
                        #line = line + '\r'
                        line = line.replace('\n', '\r\n') # LF gegen CRLF tauschen
                        conn.send(line)
                       myfile.close()
                if data == 'f':
                       print ('*Datei 10 Tage Vorhersage*') 
                       #myfile = open(".\\converted\\VHDL17_DWOG.txt",'r')
                       myfile = open(filepath + "VHDL17_DWOG.txt",'r')
                       for line in myfile :
                        #line = line + '\r'
                        line = line.replace('\n', '\r\n') # LF gegen CRLF tauschen
                        conn.send(line)
                       myfile.close()
                if data == '2' or data == 'h':
                       print ('*Datei 10 Tage Vorhersage*') 
                       #myfile = open(".\\converted\\VHDL17_DWOG.txt",'r')
                       myfile = open(filepath + "buchstaben.txt",'r')
                       for line in myfile :
                        #line = line + '\r'
                        line = line.replace('\n', '\r\n') # LF gegen CRLF tauschen
                        conn.send(line)
                       myfile.close()
                if data == '1' or data == 'g':
                       print ('*Datei 10 Tage Vorhersage*') 
                       #myfile = open(".\\converted\\VHDL17_DWOG.txt",'r')
                       myfile = open(filepath + "zahlen.txt",'r')
                       for line in myfile :
                        #line = line + '\r'
                        line = line.replace('\n', '\r\n') # LF gegen CRLF tauschen
                        conn.send(line)
                       myfile.close()
                if data == 'x' or data == 'root' or data == 'admin' or not data:
                #if not data:
                    conn.send('\r\n')  # Was muss man hier senden, damit der Kennungsgeber antwortet ?
                    #kennung = connfile.readline(1024)
                    #kennung = kennung.rstrip("\r\n")
                    #reply = 'IHRE KENNUNG : ' + kennung
                    #print(reply)
                    #conn.sendall(reply + "\r\n")
                    #conn.send(reply + "\r\n")
                    conn.send('DIE VERBINDUNG WIRD GETRENNT.\r\n' )
                    break
                #conn.sendall(reply + "\r\n")
                #conn.sendall(reply + "\r\n")
        finally:
            connfile.close()
    finally:
        # put this line in a finally block so it gets
        # executed even when an exception is thrown
        sessioncount = sessioncount - 1
        print('SITZUNG : ' + str(sessioncount) + '\r\n')
        conn.close()

#******************************************************************************* 
 
#now keep talking with the client

while 1:
    #wait to accept a connection - blocking call
    conn, addr = s.accept()
    print ('Connected with ' + addr[0] + ':' + str(addr[1]))
    #start new thread takes 1st argument as a function name to be run, second is the tuple of arguments to the function.
    #start_new_thread(clientthread ,(conn,))
    start_new_thread(clientThreadLine ,(conn,))
s.close()

Folgende Benutzer bedankten sich beim Autor ulbrichf für den Beitrag:
DL3RTL
NNNN

Gruß
Frank Ulbrich / DO2FU / 92158 ulbrichf d / TeKaDe FS220z (online) / T68D (online) / T1000S (online) / iTELEX FW 825 / TW39PLUS FW 330 / seriell speicher version FW 346 / ED1000 FW 330

Benutzeravatar

Topic author
ulbrichf
Rank 12
Rank 12
Beiträge: 646
Registriert: Sa 4. Jun 2016, 20:54
Wohnort: Grefrath, D
Hauptanschluß: 992158 ulbrichf d

Re: DWD Wetter, 727272 ulbrichf d

#6

Beitrag von ulbrichf » Mo 3. Okt 2016, 19:46

Herunterladen von Warnmeldugen und Vorhersagen.
Zu beachten ist, daß für den FTP Zugang des DWD Servers ein User und Password notwendig ist. Diese Zugangsdaten können beim DWD kostenlos beantragt werden. Im Programmtext sind diese Anmeldeinformationen herausgenommen.

2tlx_ftp_down_forecast.py : Download Forecast und Warnlagen

Code: Alles auswählen

#*********************************************************************
# Connect DWD FTP Server and download Forecast und Warnlagen
# Autor : Frank Ulbrich
# Date  : 29.09.2016
#*********************************************************************
# Links
#=======
# http://www.pythonforbeginners.com/code-snippets-source-code/how-to-use-ftp-in-python/
# 
# Server : ftp-outgoing2.dwd.de
# User : 
# PW: 
# Interpreter : python 2.7
#*********************************************************************
# Versionsnummer ausgeben
version = "0.7"

print("****************************************")
print("tlx_ftp.down FORECAST Version : " + version )
print("****************************************")

#*********************************************************************
# imported libraries
import fnmatch                          # match names
import ftplib                           # ftp connect

#*********************************************************************
# FTP Server Parameter
#*********************************************************************
filepath = "filelist/"               # Linux
#filepath = ".\\filelist\\"               # Windows
ftpserver = 'ftp-outgoing2.dwd.de'
ftpuser = 'GEHEIM'
ftppw =  'GEHEIM'
ftppath1 = '/gds/gds/specials/forecasts/text' # Infos fuer Deutschland - FPDL13*
ftppath2 = '/gds/gds/specials/forecasts/text' # Warnmeldungen - VHDL30_DWEH  WARNLAGE NRW  
ftppath3 = '/gds/gds/specials/forecasts/text' # Warnmeldungen - VHDL30_DWMG  WARNLAGE BAYERN
ftppath4 = '/gds/gds/specials/forecasts/text' # Forecast - VHDL17_DWOG  10 Tage Wettervorhersage
ftppath5 = '/gds/gds/specials/forecasts/text' # Warnmeldungen - VHDL30_DWHG  WARNLAGE NDS 
ftppath6 = '/gds/gds/specials/forecasts/text' # Warnmeldungen - VHDL30_DWPH  WARNLAGE MEG POM  
filelist1 = filepath + 'dwd_forecast_de.txt'
filelist2 = filepath + 'dwd_warnlagen_nrw.txt'
filelist3 = filepath + 'dwd_warnlagen_bay.txt'
filelist4 = filepath + 'dwd_forecast_10.txt'
filelist5 = filepath + 'dwd_warnlagen_nds.txt'
filelist6 = filepath + 'dwd_warnlagen_pom.txt'

print ("* FTP - Server Connect ")
ftp = ftplib.FTP(ftpserver, ftpuser, ftppw)
#ftp = ftplib.FTP('ftp.sunet.se', 'anonymous', 'anonymous@sunet.se')
welcome = ftp.getwelcome()
print (welcome)
ftp.dir()
ftp.cwd(ftppath1)                             #changing to forecasts
ftp.dir()

#*********************************************************************
# Read filelist Forecast Deutschland
#*********************************************************************
print ("* Read forecast filelist from ftp - server ")
filelist = []                                    # list for filenames
ftp.cwd(ftppath1)                                # changing to directory
line = ftp.retrlines("NLST",filelist.append)     # read filenames and write into list of files
print (filelist)

#*********************************************************************
# Create textfile with filenames  Forecast - Deutschland
#*********************************************************************
print ("* Create FORECAST textfile with filnames ")
# https://docs.python.org/2.7/library/fnmatch.html
myfile = open(filelist1,'w')
for item in filelist:
    if fnmatch.fnmatch(item, 'FPDL1*'):    # filter for files with specific characters
        print item
        myfile.write(item+"\n")
        #myfile.writelines("%s\n" % item)
myfile.close()

#*********************************************************************
# Read filelist FVHDL30_DWEH  WARNLAGE                            NRW 
#*********************************************************************
print ("* Read NRW filelist from ftp - server ")
filelist = []                                      # list for filenames
ftp.cwd(ftppath2)                                  # changing to 
line = ftp.retrlines("NLST",filelist.append)       # read filenames and write into list of files
filelist = sorted(filelist,reverse=True)           # Absteigende Sortierung der Namen
print (filelist)

#*********************************************************************
# Create textfile with filenames  VHDL30_DWEH  WARNLAGE            NRW 
#*********************************************************************
print ("* Create NRW textfile with filnames ")
#https://docs.python.org/2.7/library/fnmatch.html
myfile = open(filelist2,'w')

for item in filelist:
    if fnmatch.fnmatch(item, 'VHDL30_DWEH*'):    # filter for files with specific characters
        print item
        myfile.write(item+"\n")
myfile.close()


#*********************************************************************
# Read filelist FVHDL30_DWHG  WARNLAGE                             NDS 
#*********************************************************************
print ("* Read NDS filelist from ftp - server ")
filelist = []                                      # list for filenames
ftp.cwd(ftppath5)                                  # changing to 
line = ftp.retrlines("NLST",filelist.append)       # read filenames and write into list of files
filelist = sorted(filelist,reverse=True)           # Absteigende Sortierung der Namen
print (filelist)

#*********************************************************************
# Create textfile with filenames  VHDL30_DWHG  WARNLAGE            NDS 
#*********************************************************************
print ("* Create NDS textfile with filnames ")
#https://docs.python.org/2.7/library/fnmatch.html
myfile = open(filelist5,'w')

for item in filelist:
    if fnmatch.fnmatch(item, 'VHDL30_DWHG*'):    # filter for files with specific characters
        print item
        myfile.write(item+"\n")
myfile.close()


#*********************************************************************
# Read filelist  VHDL30_DWPH  WARNLAGE                             POM 
#*********************************************************************
print ("* Read POM filelist from ftp - server ")
filelist = []                                      # list for filenames
ftp.cwd(ftppath6)                                  # changing to 
line = ftp.retrlines("NLST",filelist.append)       # read filenames and write into list of files
filelist = sorted(filelist,reverse=True)           # Absteigende Sortierung der Namen
print (filelist)

#*********************************************************************
# Create textfile with filenames  VHDL30_DWPH  WARNLAGE            POM 
#*********************************************************************
print ("* Create POM textfile with filnames ")
#https://docs.python.org/2.7/library/fnmatch.html
myfile = open(filelist6,'w')

for item in filelist:
    if fnmatch.fnmatch(item, 'VHDL30_DWPH*'):    # filter for files with specific characters
        print item
        myfile.write(item+"\n")
myfile.close()


#*********************************************************************
# Read filelist FVHDL30_DWEH  WARNLAGE                         BAYERN 
#*********************************************************************
print ("* Read BAYERN filelist from ftp - server ")
filelist = []                                      # list for filenames
ftp.cwd(ftppath3)                                  # changing to 
line = ftp.retrlines("NLST",filelist.append)       # read filenames and write into list of files
filelist = sorted(filelist,reverse=True) 
print (filelist)

#*********************************************************************
# Create textfile with filenames  VHDL30_DWMG  WARNLAGE         BAYERN
#*********************************************************************
print ("* Create BAYERN  textfile with filnames ")
#https://docs.python.org/2.7/library/fnmatch.html
myfile = open(filelist3,'w')

for item in filelist:
    if fnmatch.fnmatch(item, 'VHDL30_DWMG*'):    # filter for files with specific characters
        print item
        myfile.write(item+"\n")
myfile.close()


#*********************************************************************
# Read filelist 10 Tage Forecast Deutschland
#*********************************************************************
print ("* Read 10 Tage forecast filelist from ftp - server ")
filelist = []                                    # list for filenames
ftp.cwd(ftppath4)                                # changing to directory
line = ftp.retrlines("NLST",filelist.append)     # read filenames and write into list of files
print (filelist)


#*********************************************************************
# Create textfile with filenames  Forecast - 10 Tage Deutschland
#*********************************************************************
print ("* Create 10 Tage FORECAST textfile with filnames ")
# https://docs.python.org/2.7/library/fnmatch.html
myfile = open(filelist4,'w')
for item in filelist:
    if fnmatch.fnmatch(item, 'VHDL17*'):    # VHDL17_DWOG  filter for files with specific characters
        print item
        myfile.write(item+"\n")
        #myfile.writelines("%s\n" % item)
myfile.close()


##*********************************************************************
## Read filelist DEUTSCHLAND
##*********************************************************************
#print ("* Read NDS filelist from ftp - server ")
#filelist = []                                      # list for filenames
#ftp.cwd(ftppath3)                                  # changing to Warnmeldungen SMS fuer NDS
#line = ftp.retrlines("NLST",filelist.append)       # read filenames and write into list of files
#print (filelist)

##*********************************************************************
## Create textfile with filenames  NDS
##*********************************************************************
#print ("* Create NDS textfile with filnames ")
#myfile = open(filelist3,'w')

#for item in filelist:
#    if fnmatch.fnmatch(item, '*'):    # filter for files with specific characters
#        print item
#        myfile.write(item+"\n")
#        #myfile.writelines("%s\n" % item)
#myfile.close()

#*********************************************************************
# Download textfile with filenames from saved filelist.file  Infos fuer Deutschland - FPDL13*
#*********************************************************************
print ('* Oeffne Listen Datei FDL13 : %s' %(filelist1)) 
myfile = open(filelist1,'r')
inlist = myfile.readlines()              # Using .readlines()
filelistfile =  []
for i in inlist:
    filelistfile.append(i.rstrip('\n'))  # Das Zeichen \n entgernen
myfile.close()

print("* Inlist : ")
print(inlist)
print("* Filelistfile : ")
print(filelistfile)
print ('* Download FTP Dateien') 
ftp.cwd(ftppath1) 
for takefile in filelistfile: 
    try: 
       if fnmatch.fnmatch(takefile, '*'):
        print ('* Download : %s' %(takefile)) 
        #ftp.retrlines('RETR '+takefile, open('.\\filedownload\\forecast\\' + takefile + ".txt", 'wb').write)
        ftp.retrlines('RETR '+takefile, open('filedownload/forecast/' + takefile + ".txt", 'wb').write)
        
    except :
       print ('Failed to download FTP file: %s' %(takefile)) 
       ftp.close() 


#*********************************************************************
# Download textfile with filenames from saved filelist.file Warnmeldungen - VHDL30_DWEH  WARNLAGE NRW
#*********************************************************************
print ('* Oeffne Listen Datei WARNLAGE NRW : %s' %(filelist2)) 
myfile = open(filelist2,'r')
inlist = myfile.readlines()              # Using .readlines()
filelistfile =  []
for i in inlist:
    filelistfile.append(i.rstrip('\n'))  # Das Zeichen \n entgernen
myfile.close()

print("* Inlist : ")
print(inlist)
print("* Filelistfile : ")
print(filelistfile)
print ('* Download FTP Dateien') 
ftp.cwd(ftppath2)
for takefile in filelistfile: 
    try: 
       if fnmatch.fnmatch(takefile, '*'):
        print ('* Download : %s' %(takefile)) 
        #ftp.retrlines('RETR '+takefile, open('.\\filedownload\\warnlagen\\' + takefile + ".txt", 'wb').write)
        ftp.retrlines('RETR '+takefile, open('filedownload/warnlagen/' + takefile + ".txt", 'wb').write) 
        #break                          # nur das erste Element herunterladen
    except :
       print ('Failed to download FTP file: %s' %(takefile)) 
       ftp.close() 
       

       
       
#*********************************************************************
# Download textfile with filenames from saved filelist.file Warnmeldungen - VHDL30_DWEH  WARNLAGE NDS
#*********************************************************************
print ('* Oeffne Listen Datei WARNLAGE NDS : %s' %(filelist5)) 
myfile = open(filelist5,'r')
inlist = myfile.readlines()              # Using .readlines()
filelistfile =  []
for i in inlist:
    filelistfile.append(i.rstrip('\n'))  # Das Zeichen \n entgernen
myfile.close()

print("* Inlist : ")
print(inlist)
print("* Filelistfile : ")
print(filelistfile)
print ('* Download FTP Dateien') 
ftp.cwd(ftppath5)
for takefile in filelistfile: 
    try: 
       if fnmatch.fnmatch(takefile, '*'):
        print ('* Download : %s' %(takefile)) 
        #ftp.retrlines('RETR '+takefile, open('.\\filedownload\\warnlagen\\' + takefile + ".txt", 'wb').write) 
        ftp.retrlines('RETR '+takefile, open('filedownload/warnlagen/' + takefile + ".txt", 'wb').write) 
        #break                          # nur das erste Element herunterladen
    except :
       print ('Failed to download FTP file: %s' %(takefile)) 
       ftp.close() 
       
       

#*********************************************************************
# Download textfile with filenames from saved filelist.file Warnmeldungen - VHDL30_DWPH  WARNLAGE POM
#*********************************************************************
print ('* Oeffne Listen Datei WARNLAGE POM : %s' %(filelist6)) 
myfile = open(filelist6,'r')
inlist = myfile.readlines()              # Using .readlines()
filelistfile =  []
for i in inlist:
    filelistfile.append(i.rstrip('\n'))  # Das Zeichen \n entgernen
myfile.close()

print("* Inlist : ")
print(inlist)
print("* Filelistfile : ")
print(filelistfile)
print ('* Download FTP Dateien') 
ftp.cwd(ftppath5)
for takefile in filelistfile: 
    try: 
       if fnmatch.fnmatch(takefile, '*'):
        print ('* Download : %s' %(takefile)) 
        #ftp.retrlines('RETR '+takefile, open('.\\filedownload\\warnlagen\\' + takefile + ".txt", 'wb').write) 
        ftp.retrlines('RETR '+takefile, open('filedownload/warnlagen/' + takefile + ".txt", 'wb').write)
        #break                          # nur das erste Element herunterladen
    except :
       print ('Failed to download FTP file: %s' %(takefile)) 
       ftp.close() 


#*********************************************************************
# Download textfile with filenames from saved filelist.file Warnmeldungen - VHDL30_DWEH  WARNLAGE BAYERN 
#*********************************************************************
print ('* Oeffne Listen Datei WARNLAGE BAYERN : %s' %(filelist3)) 
myfile = open(filelist3,'r')
inlist = myfile.readlines()              # Using .readlines()
filelistfile =  []
for i in inlist:
    filelistfile.append(i.rstrip('\n'))  # Das Zeichen \n entgernen
myfile.close()

print("* Inlist : ")
print(inlist)
print("* Filelistfile : ")
print(filelistfile)
print ('* Download FTP Dateien') 
ftp.cwd(ftppath3)
for takefile in filelistfile: 
    try: 
       if fnmatch.fnmatch(takefile, '*'):
        print ('* Download : %s' %(takefile)) 
        #ftp.retrlines('RETR '+takefile, open('.\\filedownload\\warnlagen\\' + takefile + ".txt", 'wb').write) 
        ftp.retrlines('RETR '+takefile, open('filedownload/warnlagen/' + takefile + ".txt", 'wb').write) 
    except :
       print ('Failed to download FTP file: %s' %(takefile)) 
       ftp.close() 
       
       
#*********************************************************************
# Download textfile with filenames from saved filelist.file  
# 10 Tage fuer Deutschland VHDL17_DWOG
#*********************************************************************
print ('* Oeffne Listen Datei VHDL17_DWOG : %s' %(filelist4)) 
myfile = open(filelist4,'r')
inlist = myfile.readlines()              # Using .readlines()
filelistfile =  []
for i in inlist:
    filelistfile.append(i.rstrip('\n'))  # Das Zeichen \n entfernen
myfile.close()

print("* Inlist : ")
print(inlist)
print("* Filelistfile : ")
print(filelistfile)
print ('* Download FTP Dateien') 
ftp.cwd(ftppath4) 
for takefile in filelistfile: 
    try: 
       if fnmatch.fnmatch(takefile, '*'):
        print ('* Download : %s' %(takefile)) 
        #ftp.retrlines('RETR '+takefile, open('.\\filedownload\\forecast\\' + takefile + ".txt", 'wb').write)
        ftp.retrlines('RETR '+takefile, open('filedownload/forecast/' + takefile + ".txt", 'wb').write)
        
    except :
       print ('Failed to download FTP file: %s' %(takefile)) 
       ftp.close() 

#*********************************************************************
# Download textfile with filenames  retrlines
#*********************************************************************
#for takefile in filelist: 
#    try: 
#       #ftp.storlines('STOR ' + file, open(file))
#        if fnmatch.fnmatch(takefile, 'H*'): 
#           ftp.retrlines('RETR '+takefile, open('.\\filedownload\\' + takefile, 'wb').write) 
#    except :
#       print ('Failed to download FTP file: %s' %(takefile)) 
#       ftp.close() 





#for item in filelist:
#  f.write("%s\n" % item)
#f.close()     

#ftp.cwd("/conspiracy") #changing to /pub/unix

#filelist = ftp.dir()

#print filelist
#ftp.retrbinary('RETR README', open('README', 'wb').write)
#ftp.retrbinary('RETR index.html', open('index.html', 'wb').write)

#filelist = ftp.nlst()
# for file in filelist:
# ftp.retrbinary('RETR '+file, open(file, 'wb').write) 

#def getFile(ftp, filename):
#    try:
#        ftp.retrbinary("RETR " + filename ,open(filename, 'wb').write)
#    except:
  #      print "Error"
#

#ASCII LINES lesen
#fd = open('README', 'wt')
#ftp.retrlines('RETR README', writeline)
#fd.close()
#ftp.quit()

#http://stackoverflow.com/questions/23624748/python-get-files-from-ftp-wildcards-and-date-changes-using
# http://ftputil.sschwarzer.net/trac/wiki/Documentation
#https://docs.python.org/3/library/fnmatch.html
#filename = 'index.html'
#localfile = open(filename, 'wb')
#ftp.retrbinary('RETR ' + filename, localfile.write, 1024)
#print 'Closing file ' + filename
#localfile.close()

print ('* Closing FTP connection')
ftp.quit()
quit()
#Ende des Program

NNNN

Gruß
Frank Ulbrich / DO2FU / 92158 ulbrichf d / TeKaDe FS220z (online) / T68D (online) / T1000S (online) / iTELEX FW 825 / TW39PLUS FW 330 / seriell speicher version FW 346 / ED1000 FW 330

Benutzeravatar

Topic author
ulbrichf
Rank 12
Rank 12
Beiträge: 646
Registriert: Sa 4. Jun 2016, 20:54
Wohnort: Grefrath, D
Hauptanschluß: 992158 ulbrichf d

Re: DWD Wetter, 727272 ulbrichf d

#7

Beitrag von ulbrichf » Mo 3. Okt 2016, 19:50

Der heruntergeladenen Text wird konvertiert, dass heißt es werden Sonderzeichen ersetzt.

3tlx_baud_conv-warn-py : Konvertierung Warnmeldungen nach Baud und Ablage unter CONVERTED

Code: Alles auswählen

# -*- coding: iso-8859-1 -*-
#*********************************************************************
# Connect Baudot Convertierung von Warnmeldungen
# Entfernung Steuerzeichen und ersetzten von CR gegen CRLF
#
# Den ersten Dateiname aus der Textliste einlesen und die Datei mit dem gelesene 
# Namen oeffnen.
#
# Autor : Frank Ulbrich
# Date : 29.09.2016
#*********************************************************************
# Links
#=======
# http://www.pythonforbeginners.com/code-snippets-source-code/how-to-use-ftp-in-python/
# Interpreter : python 2.7
#*********************************************************************
# Versionsnummer ausgeben
# -*- coding: utf-8 -*-
# -*- coding: iso-8859-1 -*-
version = "0.8"
print("****************************************")
print("tlx_baud_conv_warn.py  - Version : " + version )
print("****************************************")

#*********************************************************************
# imported libraries
import textwrap
import os
import fnmatch                          # match names
import ftplib                           # ftp connect
filepath = "filelist/"               # Linux
#filepath = ".\\filelist\\"               # Windows
#sourcepath = '.\\filedownload\\warnlagen\\'  #Windows 
sourcepath = 'filedownload/warnlagen/'   #Linux
#targetpath = '.\\converted\\' #Windows
targetpath = 'converted/' #Linux
filelist1 = filepath + 'dwd_warnlagen_nrw.txt'
filelist2 = filepath + 'dwd_warnlagen_bay.txt'
filelist3 = filepath + 'dwd_sms_de.txt'
filelist4 = filepath + 'dwd_sms_bay.txt'
filelist5 = filepath + 'dwd_warnlagen_nds.txt'
filelist6 = filepath + 'dwd_warnlagen_pom.txt'


#*********************************************************************
# convert textfile from saved filelist.file                        NRW
#*********************************************************************
print ('* Oeffne Listen Datei NRW : %s' %(filelist1)) 
myfile = open(filelist1,'r')
infile = myfile.readline()              # Using .readlines()
infile = infile[:-1] 
print ('* Dateiname NRW : %s' %(infile)) 
myfile.close()

   
print ('* Oeffnen Warn Nachrichtendatei : %s' %(infile)) 
myfile = open(sourcepath + infile+'.txt','r')
for line in myfile :
    line = line.upper()              # Konvertierung nach Kleinbuchstaben.
    #line = line[:-13]               # Ende abschneiden ->www.dwd.de
    #line = line[19:]                # Anfang abschneiden WETTERWARNUNG
    line = line.replace('Ö', 'OE')
    line = line.replace('ö', 'OE')
    line = line.replace('Ü', 'UE')
    line = line.replace('ü', 'UE')
    line = line.replace('Ä', 'AE')
    line = line.replace('ä', 'AE')
    line = line.replace('ß', 'SZ')
    line = line.replace(chr(1),'')   # Steuerzeichen SOH aus Textanfang entfernen
    line = line.replace(chr(3),'')   # Steuerzeichen ETX aus Textende entfernen
    line = line.replace('\r', '\n')
myfile.close()

#outfile = open(targetpath + infile,  "w")
outfile = open(targetpath + 'VHDL30_DWEH.txt',  "w")
outfile.write(line)
outfile.write("\nNNNN\n")
outfile.close()



print("* Inlist : ")
print(line)

#*********************************************************************
# convert textfile from saved filelist.file                        BAY
#*********************************************************************
print ('* Oeffne Listen Datei BAY : %s' %(filelist1)) 
myfile = open(filelist2,'r')
infile = myfile.readline()              # Using .readlines()
infile = infile[:-1] 
print ('* Dateiname BAY : %s' %(infile)) 
myfile.close()

   
print ('* Oeffnen Warn Nachrichtendatei : %s' %(infile)) 
myfile = open(sourcepath + infile+'.txt','r')
for line in myfile :
    line = line.upper()              # Konvertierung nach Kleinbuchstaben.
    #line = line[:-13]               # Ende abschneiden ->www.dwd.de
    #line = line[19:]                # Anfang abschneiden WETTERWARNUNG
    line = line.replace('Ö', 'OE')
    line = line.replace('ö', 'OE')
    line = line.replace('Ü', 'UE')
    line = line.replace('ü', 'UE')
    line = line.replace('Ä', 'AE')
    line = line.replace('ä', 'AE')
    line = line.replace('ß', 'SZ')
    line = line.replace(chr(1),'')   # Steuerzeichen SOH aus Textanfang entfernen
    line = line.replace(chr(3),'')   # Steuerzeichen ETX aus Textende entfernen
    line = line.replace('\r', '\n')
myfile.close()

#outfile = open(targetpath + infile,  "w")
outfile = open(targetpath + 'VHDL30_DWMG.txt',  "w")
outfile.write(line)
outfile.write("\nNNNN\n")
outfile.close()



print("* Inlist : ")
print(line)

#*********************************************************************
# convert textfile from saved filelist.file  DL30_DWHG.txt  NDS/BREMEN
#*********************************************************************
print ('* Oeffne Listen Datei NDS/BREMEN : %s' %(filelist5)) 
myfile = open(filelist5,'r')
infile = myfile.readline()              # Using .readlines()
infile = infile[:-1] 
print ('* Dateiname NDS/BREMEN : %s' %(infile)) 
myfile.close()

   
print ('* Oeffnen Warn Nachrichtendatei : %s' %(infile)) 
myfile = open(sourcepath + infile+'.txt','r')
for line in myfile :
    line = line.upper()              # Konvertierung nach Kleinbuchstaben.
    #line = line[:-13]               # Ende abschneiden ->www.dwd.de
    #line = line[19:]                # Anfang abschneiden WETTERWARNUNG
    line = line.replace('Ö', 'OE')
    line = line.replace('ö', 'OE')
    line = line.replace('Ü', 'UE')
    line = line.replace('ü', 'UE')
    line = line.replace('Ä', 'AE')
    line = line.replace('ä', 'AE')
    line = line.replace('ß', 'SZ')
    line = line.replace(chr(1),'')   # Steuerzeichen SOH aus Textanfang entfernen
    line = line.replace(chr(3),'')   # Steuerzeichen ETX aus Textende entfernen
    line = line.replace('\r', '\n')
myfile.close()

#outfile = open(targetpath + infile,  "w")
outfile = open(targetpath + 'VHDL30_DWHG.txt',  "w")
outfile.write(line)
outfile.write("\nNNNN\n")
outfile.close()



print("* Inlist : ")
print(line)
#*********************************************************************
# convert textfile from saved filelist.file                 DWPH   POM
#*********************************************************************
print ('* Oeffne Listen Datei POM : %s' %(filelist5)) 
myfile = open(filelist6,'r')
infile = myfile.readline()              # Using .readlines()
infile = infile[:-1] 
print ('* Dateiname POM : %s' %(infile)) 
myfile.close()

   
print ('* Oeffnen Warn Nachrichtendatei : %s' %(infile)) 
myfile = open(sourcepath + infile+'.txt','r')
for line in myfile :
    line = line.upper()              # Konvertierung nach Kleinbuchstaben.
    #line = line[:-13]               # Ende abschneiden ->www.dwd.de
    #line = line[19:]                # Anfang abschneiden WETTERWARNUNG
    line = line.replace('Ö', 'OE')
    line = line.replace('ö', 'OE')
    line = line.replace('Ü', 'UE')
    line = line.replace('ü', 'UE')
    line = line.replace('Ä', 'AE')
    line = line.replace('ä', 'AE')
    line = line.replace('ß', 'SZ')
    line = line.replace(chr(1),'')   # Steuerzeichen SOH aus Textanfang entfernen
    line = line.replace(chr(3),'')   # Steuerzeichen ETX aus Textende entfernen
    line = line.replace('\r', '\n')
myfile.close()

#outfile = open(targetpath + infile,  "w")
outfile = open(targetpath + 'VHDL30_DWPH.txt',  "w")
outfile.write(line)
outfile.write("\nNNNN\n")
outfile.close()



print("* Inlist : ")
print(line)


NNNN

Gruß
Frank Ulbrich / DO2FU / 92158 ulbrichf d / TeKaDe FS220z (online) / T68D (online) / T1000S (online) / iTELEX FW 825 / TW39PLUS FW 330 / seriell speicher version FW 346 / ED1000 FW 330

Benutzeravatar

Topic author
ulbrichf
Rank 12
Rank 12
Beiträge: 646
Registriert: Sa 4. Jun 2016, 20:54
Wohnort: Grefrath, D
Hauptanschluß: 992158 ulbrichf d

Re: DWD Wetter, 727272 ulbrichf d

#8

Beitrag von ulbrichf » Mo 3. Okt 2016, 20:12

sudo crontab Einträge:

Zur vollen Stunde und 35 Minuten bzw. 45 Minuten werden automatisch die folgenen shell skripte aufgerufen

Code: Alles auswählen

# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
#*/15 * * * * /usr/bin/python /home/pi/tlx_ftp_down/2tlx_ftp_down_forecast_L_v07.py > /home/pi/tlx_ftp_down/log4.txt &
35 * * * * sudo sh /home/pi/tlx_ftp_down/forecastftp.sh 2>&1 &
45 * * * * sudo sh /home/pi/tlx_ftp_down/forecastconv.sh 2>&1 &

Diese Skript rufen dann die PYTHON Programme auf.
forecastftp.sh

Code: Alles auswählen

#!/bin/bash
#This skript  starts up the python downoad skript
cd /home/pi/tlx_ftp_down
sudo /usr/bin/python /home/pi/tlx_ftp_down/2tlx_ftp_down_forecast_L_v07.py  > log2.txt
forecastconv.sh

Code: Alles auswählen

#!/bin/bash
#This skript  starts up the python convert skript
cd /home/pi/tlx_ftp_down
sudo /usr/bin/python /home/pi/tlx_ftp_down/3tlx_baud_conv-warn_L_v08.py  > log3.txt
NNNN

Gruß
Frank Ulbrich / DO2FU / 92158 ulbrichf d / TeKaDe FS220z (online) / T68D (online) / T1000S (online) / iTELEX FW 825 / TW39PLUS FW 330 / seriell speicher version FW 346 / ED1000 FW 330

Benutzeravatar

Topic author
ulbrichf
Rank 12
Rank 12
Beiträge: 646
Registriert: Sa 4. Jun 2016, 20:54
Wohnort: Grefrath, D
Hauptanschluß: 992158 ulbrichf d

Re: DWD Wetter, 727272 ulbrichf d

#9

Beitrag von ulbrichf » Mo 3. Okt 2016, 22:00

Abruf des Kennungsgebers des anrufenden Fernschreibers : conn.send('@')
NNNN

Gruß
Frank Ulbrich / DO2FU / 92158 ulbrichf d / TeKaDe FS220z (online) / T68D (online) / T1000S (online) / iTELEX FW 825 / TW39PLUS FW 330 / seriell speicher version FW 346 / ED1000 FW 330

Benutzeravatar

DF3OE
Founder
Founder
Beiträge: 1085
Registriert: Di 7. Jun 2016, 09:45
Wohnort: Edemissen- Blumenhagen
Hauptanschluß: 925302 treu d
Kontaktdaten:

Re: DWD Wetter, 727272 ulbrichf d

#10

Beitrag von DF3OE » Di 4. Okt 2016, 10:48

Hallo Frank,
ich hatte deinen Wetterdienst kürzlich mal getestet. Tolle Sache!
Was mir aufgefallen ist:

- Kennungsgeber beginnt mit WZ + ZV und endet nicht damit. ;-)
- Die Verbindung wurde nach Abruf der "Wetter Prosa" von dir aus sofort getrennt.

Ansonsten, weiter so!

mfg
henning +++
mfg
henning +++

925302 treu d - T1000Z (Hauptanschluss)
55571 fvler a - T100S
218308 test d - T1000S/LS (Werkstatt)
733760 egon dk - GNT5 (Werkstatt)
92612a treu d - T1200SD (Listenabruf KLKL)

Antworten

Zurück zu „i-Telex Dienste“