예제 #1
0
def show():
    x = entry_city.get()
    y = enter_lat.get()
    z = enter_lon.get()
    print(x)
    print(y)
    print(z)


    if x != "":

        url = "https://api.openweathermap.org/data/2.5/weather?q={}&appid=c3496ec82796d53908eb44fff87eac32&units=metric".format(
            x)
        res = requests.get(url)
        data = res.json()
    else:

        res = requests.get('https://ipinfo.io/')
        data = res.json()
        # location = data['loc'].split(',')
        # latitude = location[0]
        # longitude = location[1]
        url = 'http://api.openweathermap.org/data/2.5/weather?lat={}&lon={}&APPID=d1a7ed688e1b9155f95106d9a55b9ab0&units=metric'.format(
            y, z)

        res = requests.get(url)
        data = res.json()

    temp = str(data['main']['temp']) + '  degree celcius'
    pressure = str(data['main']['pressure']) + ' hPa'
    humidity = str(data['main']['humidity']) + '%'
    wind_speed = str(data['wind']['speed']) + 'm/s'
    latitude = data['coord']['lat']
    longitude = data['coord']['lon']
    name = data ['name']
    description = data['weather'][0]['description']
    country = data['sys']['country']

    print('Temperature : {} degree calcius'.format(temp))
    print('Wind Speed : {} m/s'.format(wind_speed))
    print('Latitude : {}'.format(latitude))
    print('Longitude : {}'.format(longitude))
    print('description : {}'.format(description))
    print('pressure : {}'.format(pressure))
    print('humidity : {}'.format(humidity))
    print('Country:{}'.format(country))
    current_date = datetime.date.today()
    print(current_date)


    date.config(text=current_date,font='bold 20')
    mi.config(text=temp)
    mi1.config(text=wind_speed)
    mi2.config(text=latitude)
    mi3.config(text=longitude)
    mi4.config(text=description)
    mi5.config(text=pressure)
    mi6.config(text=humidity)
    mi7.config(text=name)
def show():
    root.geometry("350x500")
    x = (entry_city.get())
    print(x)
    url = 'http://api.openweathermap.org/data/2.5/weather?q={}&APPID=d1a7ed688e1b9155f95106d9a55b9ab0&units=metric'.format(
        x)
    res = requests.get(url)
    data = res.json()
    temp = str(data['main']['temp']) + ' degree celcius'
    wind_speed = str(data['wind']['speed']) + ' m/s'
    latitude = data['coord']['lat']
    longitude = data['coord']['lon']
    description = data['weather'][0]['description']
    pressure = str(data['main']['pressure']) + ' hPa'
    temp_max = str(data['main']['temp_max']) + ' degree celsius'
    temp_min = str(data['main']['temp_max']) + ' degree celsius'
    humidity = str(data['main']['humidity']) + ' %'
    country = data['sys']['country']
    wind_direction = str(data['wind']['deg']) + ' degree'
    pprint(data)
    print('Temperature:{} '.format(temp))
    print('wind speed:{}'.format(wind_speed))
    print('Latitude:{}'.format(latitude))
    print('Longitude:{}'.format(longitude))
    print('Description:{}'.format(description))
    print('Pressure:{}'.format(pressure))
    print('Temperature max:{} '.format(temp_max))
    print('Temperature min:{} '.format(temp_min))
    print('Humidity:{}'.format(humidity))
    print('Country:{}'.format(country))
    print('Wind Direction:{}'.format(wind_direction))

    current_date = datetime.date.today()
    print(current_date)

    date.config(text=current_date)
    city.config(text=x)
    l.config(text=temp)
    l1.config(text=wind_speed)
    l2.config(text=latitude)
    l3.config(text=longitude)
    l4.config(text=description)
    l5.config(text=pressure)
    l6.config(text=temp_max)
    l7.config(text=temp_min)
    l8.config(text=humidity)
    l9.config(text=country)
    l10.config(text=wind_direction)
예제 #3
0
def show():
    root.geometry("350x500")
    x=(entry_city.get())
    print(x)
    url='http://api.openweathermap.org/data/2.5/weather?q={}&APPID=d1a7ed688e1b9155f95106d9a55b9ab0&units=metric'.format(x)
    res=requests.get(url)
    data=res.json()
    temp=str(data['main']['temp'])+' degree celcius'
    wind_speed=str(data['wind']['speed'])+' m/s'
    latitude=data['coord']['lat']
    longitude=data['coord']['lon']
    description=data['weather'][0]['description']
    pressure=str(data['main']['pressure'])+' hPa'
    temp_max=str(data['main']['temp_max'])+' degree celsius'
    temp_min=str(data['main']['temp_max'])+' degree celsius'
    humidity=str(data['main']['humidity'])+' %'
    country=data['sys']['country']
    wind_direction=str(data['wind']['deg'])+' degree'
    pprint(data)
    print('Temperature:{} '.format(temp))
    print('wind speed:{}'.format(wind_speed))
    print('Latitude:{}'.format(latitude))
    print('Longitude:{}'.format(longitude))
    print('Description:{}'.format(description))
    print('Pressure:{}'.format(pressure))
    print('Temperature max:{} '.format(temp_max))
    print('Temperature min:{} '.format(temp_min))
    print('Humidity:{}'.format(humidity))
    print('Country:{}'.format(country))
    print('Wind Direction:{}'.format(wind_direction))

    current_date = datetime.date.today()
    print(current_date)


    date.config(text=current_date)
    city.config(text=x)
    l.config(text=temp)
    l1.config(text=wind_speed)
    l2.config(text=latitude)
    l3.config(text=longitude)
    l4.config(text=description)
    l5.config(text=pressure)
    l6.config(text=temp_max)
    l7.config(text=temp_min)
    l8.config(text=humidity)
    l9.config(text=country)
    l10.config(text=wind_direction)
예제 #4
0
def show():
    root.geometry("500x500")
    x = entry_box.get()

    if x != "":
        url = 'http://api.openweathermap.org/data/2.5/weather?q={}&APPID=c6efb3a6470e111b194bbb6f28160609&units=metric'.format(
            x)
        res = requests.get(url)
        data = res.json()
    else:
        entry_box.insert(END, "Invalid Entry")

    temp = str(data['main']['temp']) + ' degree celcius'
    wind_speed = str(data['wind']['speed']) + ' m/s'
    latitude = data['coord']['lat']
    longitude = data['coord']['lon']
    description = data['weather'][0]['description']
    pressure = str(data['main']['pressure']) + ' hPa'
    temp_max = str(data['main']['temp_max']) + ' degree celsius'
    temp_min = str(data['main']['temp_max']) + ' degree celsius'
    humidity = str(data['main']['humidity']) + ' %'
    name = data['name']

    current_date = datetime.date.today()

    date.config(text=current_date)
    city.config(text=name)
    la.config(text=temp)
    la1.config(text=wind_speed)
    la2.config(text=latitude)
    la3.config(text=longitude)
    la4.config(text=description)
    la5.config(text=pressure)
    la6.config(text=temp_max)
    la7.config(text=temp_min)
    la8.config(text=humidity)
예제 #5
0
def show():
    root.geometry("450x500")
    x = entry_city.get()
    y = entry_lat.get()
    z = entry_lon.get()
    print(x)
    print(y)
    print(z)

    if x != "":

        url = 'http://api.openweathermap.org/data/2.5/weather?q={}&APPID=08dd5fc9b6986b5346acac964e572f3b&units=metric'.format(
            x)
        res = requests.get(url)
        data = res.json()
    else:

        res = requests.get('https://ipinfo.io/')
        data = res.json()

        url = 'http://api.openweathermap.org/data/2.5/weather?lat={}&lon={}&APPID=08dd5fc9b6986b5346acac964e572f3b&units=metric'.format(
            y, z)

        res = requests.get(url)
        data = res.json()

    temp = str(data['main']['temp']) + ' degree celcius'
    wind_speed = str(data['wind']['speed']) + ' m/s'
    latitude = data['coord']['lat']
    longitude = data['coord']['lon']
    description = data['weather'][0]['description']
    pressure = str(data['main']['pressure']) + ' hPa'
    temp_max = str(data['main']['temp_max']) + ' degree celsius'
    temp_min = str(data['main']['temp_max']) + ' degree celsius'
    humidity = str(data['main']['humidity']) + ' %'
    country = data['sys']['country']
    name = data['name']
    pprint(data)
    print('Temperature:{} '.format(temp))
    print('wind speed:{}'.format(wind_speed))
    print('Latitude:{}'.format(latitude))
    print('Longitude:{}'.format(longitude))
    print('Description:{}'.format(description))
    print('Pressure:{}'.format(pressure))
    print('Temperature max:{} '.format(temp_max))
    print('Temperature min:{} '.format(temp_min))
    print('Humidity:{}'.format(humidity))
    print('Country:{}'.format(country))
    print('Name:{}'.format(name))

    current_date = datetime.date.today()
    print(current_date)

    date.config(text=current_date)
    city.config(text=name)
    l.config(text=temp)
    l1.config(text=wind_speed)
    l2.config(text=latitude)
    l3.config(text=longitude)
    l4.config(text=description)
    l5.config(text=pressure)
    l6.config(text=temp_max)
    l7.config(text=temp_min)
    l8.config(text=humidity)
    l9.config(text=country)
예제 #6
0
def show():
    root.geometry("400x500")
    x = entry_city.get()
    y = enter_lat.get()
    z = enter_lon.get()
    print(x)
    print(y)
    print(z)

    if x != "":

        url = 'http://api.openweathermap.org/data/2.5/weather?q={}&APPID=c6efb3a6470e111b194bbb6f28160609&units=metric'.format(
            x)

        res = requests.get(url)
        data = res.json()
    else:

        res = requests.get('https://ipinfo.io/')
        data = res.json()
        # location = data['loc'].split(',')
        # latitude = location[0]
        # longitude = location[1]
        url = 'http://api.openweathermap.org/data/2.5/weather?lat={}&lon={}&APPID=c6efb3a6470e111b194bbb6f28160609&units=metric'.format(
            y, z)

        res = requests.get(url)
        data = res.json()
    temp = str(data['main']['temp']) + ' degree celcius'
    wind_speed = str(data['wind']['speed']) + ' m/s'
    latitude = data['coord']['lat']
    longitude = data['coord']['lon']
    description = data['weather'][0]['description']
    pressure = str(data['main']['pressure']) + ' hPa'
    temp_max = str(data['main']['temp_max']) + ' degree celsius'
    temp_min = str(data['main']['temp_max']) + ' degree celsius'
    humidity = str(data['main']['humidity']) + ' %'
    name = data['name']
    pprint(data)
    print('Temperature:{} '.format(temp))
    print('wind speed:{}'.format(wind_speed))
    print('Latitude:{}'.format(latitude))
    print('Longitude:{}'.format(longitude))
    print('Description:{}'.format(description))
    print('Pressure:{}'.format(pressure))
    print('Temperature max:{} '.format(temp_max))
    print('Temperature min:{} '.format(temp_min))
    print('Humidity:{}'.format(humidity))
    print('Name :{}'.format(name))

    current_date = datetime.date.today()
    print(current_date)

    date.config(text=current_date)
    city.config(text=name)
    la.config(text=temp)
    la1.config(text=wind_speed)
    la2.config(text=latitude)
    la3.config(text=longitude)
    la4.config(text=description)
    la5.config(text=pressure)
    la6.config(text=temp_max)
    la7.config(text=temp_min)
    la8.config(text=humidity)
예제 #7
0
def grad_date():
    date.config(text="Selected Date is: " + cal.get_date())
    date_c = cal.get_date()
    date_list = date_c.split(".")
    month = [
        'JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT',
        'NOV', 'DEC'
    ]

    file_start = str(y) + date_list[1] + date_list[0]
    file_end = "*.xml"

    ch_dir = '\\\\150.1.62.26\\' + str(y) + '\\' + month[
        int(date_list[1]) - 1] + '-' + date_list[2]

    #creating month folder in required destination using date format
    if not os.path.exists(ch_dir):
        os.mkdir(ch_dir)

    os.chdir(ch_dir)

    #creating date folder in required destination using date format
    if not os.path.exists(date_c):
        os.mkdir(date_c)

    src = "\\\\150.1.62.2\MottaiXML\\"

    #src = "E:\Projects\LimitPY\FinalProjectBefore_run\src\\"
    #dst = "E:\Projects\LimitPY\FinalProjectBefore_run\dst"

    dst = ch_dir + "\\" + date_c
    #dst = "\\\\150.1.62.26\\2021\MAR-21\\" + "test"

    cmd = "copy " + src + file_start + file_end + ' ' + dst
    os.system(cmd)

    os.chdir(dst)

    cli_files = os.listdir('.')

    for cl_file in cli_files:
        if cl_file.endswith("-clients-RBS.xml"):
            xml_to_read = cl_file
            break

    tree = ET.parse(xml_to_read)
    root = tree.getroot()
    print('Client Code', '\t\t[Old]', '\t\t[New]')
    for limit in root.findall(
            'Limits'
    ):  # using root.findall() to avoid removal during traversal
        client = str(limit.find('ClientCode').text)
        cash = limit.find('Cash').text

        new_cash = limit_file.get(
            client, 'noNeed')  #collecting cash limit if required to change
        #print(client,': ',new_cash)

        mobile_limit = mobile_code.get(client,
                                       'noNeed')  #collecting mobile limit

        if new_cash != 'noNeed' and int(new_cash) > int(cash):
            limit.find('Cash').text = new_cash
            print(client, '\t\t', cash, '\t\t', new_cash)

        if mobile_limit != 'noNeed':
            limit.find('Cash').text = mobile_limit
            print(client, '\t\t', cash, '\t\t', mobile_limit, '\tMobile code')

    tree.write('new.xml')

    toFormatXML = open("new.xml", "r")
    content = toFormatXML.read()
    toFormatXML.close()
    os.remove("new.xml")
    os.remove(xml_to_read)
    firstLine = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n"

    formatXML = open(xml_to_read, "w")
    formatXML.write(firstLine)
    formatXML.write(content)
    formatXML.close()
    print("Done")