Code Monkey home page Code Monkey logo

ansiweather's People

Contributors

andreineculau avatar bszcz avatar drewx0r avatar er0k avatar fcambus avatar johnkacz avatar joshmoore avatar jwilk avatar krytarowski avatar livibetter avatar lornix avatar lucc avatar matthewfranglen avatar mdom avatar mfontani avatar michaelhood avatar mreinhardt avatar nikcorg avatar pianojockl avatar qbit avatar royhodgman avatar rpdelaney avatar sesm avatar sorbits avatar sshaw avatar thirota avatar tomef avatar web-mech avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansiweather's Issues

get parse error: Invalid literal at line 1, column 4

Hi all.
Made the following .ansiweatherrc

location:Pune,IN
fetch_cmd:ftp -V -o -
symbols:false
forecast:5
#dateformat:%d-%m-%Y

I thought it's possible that the dateformat is malformed or something and that's why it wasn't working.

This is the error it generates :-

$ ansiweather
parse error: Invalid literal at line 1, column 4
ERROR : Cannot fetch weather data for the given location

ERROR: Cannot fetch weather data for the given location

The file ~/.ansiweatherrc contains the following:

location:4256038
fetch_cmd:ftp -V -o -
units:imperial
show_daylight:true
forecast:5
symbols:true
show_humidity:true

And I get the error

ERROR: Cannot fetch weather data for the given location

Whitespace on first line of output

Hi -

When running ansiweather, I am getting a whitespace as the first character on the first line of output.

$ansiweather
 Weather in London  58 °F
Wind  11.41 mph E
Humd  67 %
Pres  30.21 inHg
SunR  May 18 05:03
SunS  May 18 20:51

Also, is there a way to override the "Weather in" text and just have "Temp" for the output?

Edit: Bash 4.4.19 on Mac High Sierra, if that makes any difference.

Use HTTPS?

Hey, thanks for making this!

I just give it a try, replacing http: with https: everywhere and the script still works fine. Any reason to not switch over?

Thanks!

-r

ERROR: Cannot fetch weather data if there is no space

Hi there

I'm getting the error "ERROR: Cannot fetch weather data" if my location in my ansiweatherrc was location:Detroit,MI

I went out on a limb and added a space

location:Detroit, MI

and it worked. Not sure if you can document this or provide more error details or workaround? Thanks for the great tool :)

Location names with spaces in need to be encoded

I live in Kuala Lumpur, Malaysia. Setting the location in .ansiweatherrc as "Kuala Lumpur,MY" causes the fetch to openweathermap.org to fail (the spaces are not escaped when passed to the fetch command).

Workaround is to set the location in the rc file as "Kuala+Lumpur,MY" which works as expected.

greeting_text and text parsing error

As you now have two settings which both contain the text fragment "text" parsing confuses the two, prepending ^ in the grep line fixes this:

ret=$(grep "^$1" $config_file | awk -F: '{print $2}')

have a switch so that the weather uses terms instead of symbols.

Hi all,
It would be nice if at the output used terms instead of symbol, this is useful and necessary both from accessibility viewpoint and sharing the content with others who might not have the symbol font/unicode at their end (I am guessing the symbol font is unicode-based).

Use Lat Long for weatherlookups

The city list from weathermap contains a lot of duplicate city names, because they are in different states. This can lead to very strange results in the US and I imagine in other countries with duplicated city names. The telize api provides the latitude and longitude in the response and the openweathermap API also allows for queries to use lat/long instead of city id / city name. It would be nice if you used the lat/long instead of city names.

Change rc filepath

Hi,
I would like have many rc config file. I have already fixed this issue.
I have also added a config for change default color.

My patch :

diff --git a/ansiweather b/ansiweather
index 6bdc60b..b4ad6a7 100755
--- a/ansiweather
+++ b/ansiweather
@@ -19,7 +19,12 @@

 LC_NUMERIC=C

-config_file=~/.ansiweatherrc
+if [ $# -gt 0 ]
+then
+    config_file=$1
+else
+    config_file=~/.ansiweatherrc
+fi

 function get_config {
    ret=""
@@ -110,6 +115,7 @@ done

 #### [ Colors and characters ]#################################################

+initialize_color=$(get_config "initialize_color" || echo "\033[0m")
 background=$(get_config "background" || echo "\033[44m")
 text=$(get_config "text" || echo "\033[36;1m")
 data=$(get_config "data" || echo "\033[33;1m")
@@ -348,7 +354,7 @@ then
            output="$output$dashes "
        fi
    done
-   output="$output\033[0m"
+   output="$output$initialize_color"
    echo -e "$output"
 else
    if [ $symbols = true ]
@@ -362,7 +368,7 @@ else
        output="$output $dashes$text $sunrise_text $delimiter$data $sunrise_time $dashes$text $sunset_text $delimiter$data $sunset_time"
    fi

-   output="$output \033[0m"
+   output="$output$initialize_color"

    echo -e "$output"
 fi

Sorry for my english,
Marc

ERROR : Cannot find jq binary

I'm on OSX, installed through Homebrew. If I run from the command line, it works fine. But if I put the command in my crontab, I get this error even though I do have jq installed.

Is this possibly an issue with where Homebrew installs binaries? Why can't it find the jq binary?

Change location in ansiweatherrc.example

Hello, my name is Thomas and i am not used to github and cmd that much i need this nice tool for a project. I just need to change the default settings specifically the location. I open the ansiweatherrc.example with nano and type location:Corfu,GR and then save it. When i run the command ansiweather it just displays the default location again and not mine. Am i doing something wrong? (I just need to change the default settings in order not to use location -l command).
Thank you!

Multiple word cities used to work, now don't

I used to use the following command to get the weather in New Orleans, Louisiana, USA:
ansiweather -l New_Orleans,LA

This now returns ERROR: Cannot fetch weather data

This error appears no matter what format I use (quotes, backslash to escape the space, US instead of LA, etc.)

I've used the openweathermap city ID as a workaround, but it's unfortunate that some variation of the actual city name can't be used for multi-word cities.

default and config outputs mutually exclusive?

when running the command with default, i see the standard wind & temp & humidity data. when i rerun with my rc file, i get the options i've specified, but not the default info. are the two outputs mutually exclusive? i've opened up the code, but it might be above my skill level. is there a way to combine the two outputs, e.g.:

Current weather in Yourtown => 76 °F ☔ - Wind => 3.89 mph SE - Humidity => 94 % - Pressure => 30.00 inHg
Yourtown forecast =>
Tue Aug 02: 80/74 °F ☔
Wed Aug 03: 80/74 °F ☁
Thu Aug 04: 82/74 °F ☁
Fri Aug 05: 84/73 °F ☔
Sat Aug 06: 90/77 °F ☔

jq : command not found && [ : unary operator expected

Here is the output I get when running ./ansiweather:

➜ ansiweather git:(master) ./ansiweather
./ansiweather: line 76: jq: command not found
./ansiweather: line 77: jq: command not found
./ansiweather: line 78: jq: command not found
./ansiweather: line 79: jq: command not found
./ansiweather: line 80: jq: command not found
./ansiweather: line 81: jq: command not found
./ansiweather: line 82: jq: command not found
./ansiweather: line 90: [: 1382430452: unary operator expected
./ansiweather: line 90: [: 1382430452: unary operator expected

I am running:
➜ ansiweather git:(master) zsh --version
zsh 4.3.10 (x86_64-unknown-linux-gnu)

on:
➜ ~ cat /proc/version
Linux version 2.6.32-358.18.1.el6.x86_64 ([email protected]) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Tue Aug 27 14:23:09 CDT 2013

Include help

Hey! Cool little utility.
Perhaps include a --help or -h or help or man ansiweather feature? :)
/Storm

wind direction not customizable

If your language doesn't have the same convention that NESW are the directions, you need to change the script itself, which risks getting overwritten in a package update.

If line 240 where you set the wind directions is put into the .ansiweatherrc and pulled from there, it would be customizable as well.

Same goes for the replacement of the word 'forecast'.

Dates in ISO-8601 format

Hi,

I'm trying to make ansiweather 1.12.0 on macOS output the time and date in an ISO-8601 compatible format.

On Linux, date -I can be used for outputting an ISO-8601 compatible time and date, but this is not supported on UNIX or macOS.

I tried the following in ~/.ansiweatherrc:

dateformat:%Y-%m-%d
timeformat:%H:%M

(based on this stackoverflow answer).

The date looks right, but I am unable to see if the timeformat appears correctly.

Feature request: Could there be an option for only using ISO-8601 compatible time and dates?

Thanks for creating ansiweather.

Best regards,
Alexander F. Rødseth

Output doesn't fit on one line

When running ansiweather I get the following output:

As you can see it doesn't fit on one line with the standard 80 columns.

The contents of my ~/.ansiweatherrc is:

location:Aarhus,DK
units:metric
symbols:true

Proxy

I'm working in a Cygwin Shell on a Windows 7 System behind a proxy. Running ./ansiweather results in the following error:

ERROR : Cannot fetch weather data

It seems there are not options to pass proxy settings. So I suggest to evaluate the environment variables HTTP_PROXY and HTTPS_PROXY.

No support for spaces

First, great script!

Adding "San Jose,CA" fails where any city w/out a space works like a champ.

Thanks,

fails with parse errors

$ ./ansiweather
parse error: Invalid literal
parse error: Invalid literal
parse error: Invalid literal
parse error: Invalid literal
parse error: Invalid literal
parse error: Invalid literal
parse error: Invalid literal
./ansiweather: line 90: [: 1382381697: unary operator expected
./ansiweather: line 90: [: 1382381697: unary operator expected
Current weather in => °C - Humidity => % - Pressure => hPa

My .ansiweatherrc looks like this:
cat /.ansiweatherrc
location:Moscow,RU
fetch_cmd:ftp -V -o -
units:metric
blutgens@sputnik:
/ansiweather$

~/ansiweather$ jq --version
jq version 1.2

is this still working?

./ansiweather -l Augustow -u metric -s true -k .... -i true -w true -h true -p true -d true
ERROR: Cannot fetch weather data

what could go wrong? where to check it?

Temperature not displayed correctly

Hi,

I live in San Jose, CA. I input "San Jose, CA" in .ansiweatherrc as my location. This is correctly interpreted (San%20Jose,CA) by the OpenWeather API. I have units:imperial set.

This is what I see:
Current weather in San => 307.937 °F ☀ - Humidity => 46 % - Pressure => 987.89 hPa

Temp is a bit high :).

(standard_in) 1: parse_error

An issue without too much context as I cannot reproduce again (it might be related to the temperature being 0).

(standard_in) 1: parse error
 Current weather in  => 0 °C - Wind =>  m/s N - Humidity =>  % - Pressure => 0 hPa

~/.ansiweatherrc

location:Stockholm,SE
units:metric
symbols:true

Multiple word city names do not return expected output

You have to enter Los Angeles as losangeles to avoid this problem despite it being listed on the city page as "Los Angeles." Additionally entering cities as multiple words ignores the rest of the entry, defaulting the output to current weather (not forecast) and metric.

For example:

ansiweather -l Los Angeles,US -u imperial -s true -f 5 -d true gives the output Current weather in Kingdom of Sweden => 7 °C ☀ - Wind => 1.47 m/s NW - Humidity => 50 % - Pressure => 988 hPa whereas ansiweather -l losangeles,us -u imperial -s true -f 5 -d true or ansiweather -l "Los Angeles",us -u imperial -s true -f 5 -d true (although the latter seems slower on my end) gives the output Los Angeles forecast => Sun Apr 10: 67/57 °F ☔ - Mon Apr 11: 66/52 °F ☔ - Tue Apr 12: 70/43 °F ☀ - Wed Apr 13: 68/44 °F ☀ - Thu Apr 14: 60/48 °F ☔ .

Even if this is not fixed, it would be great if it could be better explained in the README.

Path Directory Separators?

Would it be possible to add an option to use symbols for the separation between directories in the current path? I attached a screen shot that I found, I'm not sure how the look was achieved in the screen shot.
687474703a2f2f7777772e67657870657274732e636f6d2f696d672f7465726d696e69782f7465726d696e697831312e706e67

(I apologize if this is already possible. I couldn't seem to find anything documenting this, although I didn't really know what to search.)

set LC_NUMERIC=C for locales that use a comma instead of a period for decimals

My locale is set to nl_NL.UTF-8 and we use comma's for decimal numbers.
For example: we use 18,5 instead of 18.5

This will cause this error:
./ansiweather: line 77: printf: 18.453: invalid number

Solution: put this line somewhere near the start:
LC_NUMERIC=C

This may also prevent errors if you want to use latitude and longitude in the future.

Readability: modify output colors

This tool is fantastic, but I struggle heavily reading the results, especially with the blue background.
Is there a possibility to modify the colors?

screen shot 2016-10-24 at 1 54 55 pm

I'd also like to mention that the following is no good solution for readability as well

-a value Toggle ANSI colors display ( true or false )

screen shot 2016-10-24 at 4 12 18 pm

It'd be best for readability if only the background disappeared instead of all the colors.

BSD date is not compatible with GNU date

Looks like the script uses BSD date options,

ansiweather -f 5
date: invalid option -- 'j'
Try 'date --help' for more information.
date: invalid option -- 'j'
Try 'date --help' for more information.
date: invalid option -- 'j'
Try 'date --help' for more information.
date: invalid option -- 'j'
Try 'date --help' for more information.
date: invalid option -- 'j'
Try 'date --help' for more information.
Istanbul forecast => : 17/15 °C ☁ - : 15/12 °C ☔ - : 16/12 °C ☀ - : 16/13 °C ☀ - : 17/11 °C ☀

Garbled output

In the following please ignore the bold fonts: I didn't find an option to disable Markdown tags.

Pulled and used ansiweather version is from today, 2017-11-02

In the .ansiweather dir:

$ diff -u ansiweatherrc.example ~/.ansiweatherrc
--- ansiweatherrc.example 2017-11-02 14:06:30.357657188 +0100
+++ /home/[deleted-username]/.ansiweatherrc 2017-11-02 16:03:33.113102106 +0100
@@ -2,17 +2,17 @@

api_key:85a4e3c55b73909f42c6a23ec35b7147
fetch_cmd:curl -sf
-location:Rzeszow,PL
+location:Stuttgart,DE
units:metric
forecast:0
ansi:true
-symbols:false
+symbols:true
show_wind:true
-show_humidity:true
-show_pressure:true
-show_daylight:false
+show_humidity:false
+show_pressure:false
+show_daylight:true
dateformat:%a %b %d
-timeformat:%b %d %r
+timeformat:%b %d %R

Text and Colors

background:\033[44m

========================

./ansiweather -l Rzeszow,PL -u metric -s false -d true
\033[44m\033[36;1m Weather in Rzeszow \033[35m=>\033[33;1m 8 °C \033[34m-\033[36;1m Wind \033[35m=>\033[33;1m 9.8 m/s SW \033[34m-\033[36;1m Sunrise \033[35m=>\033[33;1m Nov 02 06:24 \033[34m-\033[36;1m Sunset \033[35m=>\033[33;1m Nov 02 16:05

or:
$ ./ansiweather -l Rzeszow,PL -u metric -s true -f 5 -d true
\033[44m\033[36;1m Rzeszow forecast \033[36;1m\033[35m=> \033[36;1mThu Nov 02: \033[33;1m8\033[36;1m/\033[33;1m7 °C \033[37;1m\xe2\x98\x94 \033[34m- \033[36;1mFri Nov 03: \033[33;1m8\033[36;1m/\033[33;1m7 °C \033[37;1m\xe2\x98\x94 \033[34m- \033[36;1mSat Nov 04: \033[33;1m10\033[36;1m/\033[33;1m5 °C \033[33;1m\xe2\x98\x80 \033[34m- \033[36;1mSun Nov 05: \033[33;1m9\033[36;1m/\033[33;1m5 °C \033[37;1m\xe2\x98\x81 \033[34m- \033[36;1mMon Nov 06: \033[33;1m9\033[36;1m/\033[33;1m3 °C \033[37;1m\xe2\x98\x94
]$

or
./ansiweather -a false -l Rzeszow,PL -u metric -s true -f 5 -d true
\033[44m\033[36;1m Rzeszow forecast \033[36;1m\033[35m=> \033[36;1mThu Nov 02: \033[33;1m8\033[36;1m/\033[33;1m7 °C \033[37;1m\xe2\x98\x94 \033[34m- \033[36;1mFri Nov 03: \033[33;1m8\033[36;1m/\033[33;1m7 °C \033[37;1m\xe2\x98\x94 \033[34m- \033[36;1mSat Nov 04: \033[33;1m10\033[36;1m/\033[33;1m5 °C \033[33;1m\xe2\x98\x80 \033[34m- \033[36;1mSun Nov 05: \033[33;1m9\033[36;1m/\033[33;1m5 °C \033[37;1m\xe2\x98\x81 \033[34m- \033[36;1mMon Nov 06: \033[33;1m9\033[36;1m/\033[33;1m3 °C \033[37;1m\xe2\x98\x94

]$ ./ansiweather -a false -l Rzeszow,PL -u metric -s false -f 5 -d true
\033[44m\033[36;1m Rzeszow forecast \033[36;1m\033[35m=> \033[36;1mThu Nov 02: \033[33;1m8\033[36;1m/\033[33;1m7 °C \033[34m- \033[36;1mFri Nov 03: \033[33;1m8\033[36;1m/\033[33;1m7 °C \033[34m- \033[36;1mSat Nov 04: \033[33;1m10\033[36;1m/\033[33;1m5 °C \033[34m- \033[36;1mSun Nov 05: \033[33;1m9\033[36;1m/\033[33;1m5 °C \033[34m- \033[36;1mMon Nov 06: \033[33;1m9\033[36;1m/\033[33;1m3 °C
]$

This is happening on Fedora 26, linux 4.13.9-200.fc26.x86_64, GNOME Terminal 3.24.2, GNOME Shell 3.24.3.

Installed today:
jq-1.5-6.fc26.x86_64
oniguruma-6.4.0-1.fc26.x86_64

I logged out of X/Gnome and in again after the the jq/oniguruma install. But didn't reboot.

bc.x86_64 version is 1.06.95-18.fc26

And similar results as above with an xterm XTerm(327) on the same Gnome/Fedora environment.

HTH
Wolfgang

Doesn't seem to match OpenWeatherMap data

Not sure how this would happen, but the temperatures I'm seeing in my terminal:

% ansiweather -F -l Siren,US
 Siren forecast: Tue Jun 16: 80/66 °F ☁ - Wed Jun 17: 79/62 °F ☀ - Thu Jun 18: 76/62 °F ☔ - Fri Jun 19: 75/56 °F ☀ - Sat Jun 20: 65/54 °F ☔ 

don't seem to match what I see in the OpenWeatherMap web site at https://openweathermap.org/city/5273324:

Screen Shot 2020-06-16 at 10 38 39 AM

And unfortunately neither of these are very consistent with weather.com's forecast (seen here through Google's results):

Screen Shot 2020-06-16 at 10 42 15 AM

I would chalk this up to uncertainty, but a ten-degree discrepancy in the current day's forecast (it's 10:45 local time here, so the high is only a couple hours in the future) seems like quite a lot to just be model disagreement. Maybe OpenWeatherMap is inconsistent with both itself and the real world right now?

Switch fetch_cmd default value to ftp?

ftp is available by default on *BSD systems and Mac OS X, so users of those systems only need 'jq' as a dependency. On Linux curl needs to be installed anyway so it would just mean switching dependency from curl to ftp.

Some testing should be done on all systems.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.