GithubHelp home page GithubHelp logo

weathersim's People

Contributors

dependabot[bot] avatar haugenbits avatar henrikeide avatar kimandreg avatar mrtineide avatar stalej avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

weathersim's Issues

client_server.py talking to database

  • Retrieve all json data
  • Parse data on server side for request
  • Implement -> getall, close, help
  • Implement -> getplace
  • Implement -> getrain
  • Implement -> gettemp

Fix broken get all command

This method is flawed. We need to make a second request to find the size file we are sending.

def request_to_server(request: str) -> str:
    sock.sendall(request.encode())
    resp = sock.recv(16384)
    return resp.decode()

We need

sock.reciv(file_size)

So that we don't overflow the recv buffer

Catch OSError by error code

Må finne en måte å catche OSError

  • Arbeidsoppgave:
    • finne en måte å catche OSError
    • klare å catche OSError error code

get data all fails in WeatherAppClient.py

Error when trying to fetch all data form data.json

WAclient> get data all
Traceback (most recent call last):
  File "WeatherAppClient.py", line 107, in <module>
    get_all_data()
  File "WeatherAppClient.py", line 29, in get_all_data
    all_data = get_json("getall")  # loads converts str -> dict
  File "WeatherAppClient.py", line 16, in get_json
    _data = json.loads(request_to_server(request))
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 1 (char 0)

README fix

A small error in the readme. data sender is not on the server but station

$ python server/server.py
$ python server/weather_station_data_sender.py
$ python server/client_server.py
$ python client/WeatherAppClient.py

Either the Readme is not correct or the code is not correct

Describe the bug:
When in the project root directory, if you run the code from as described in the readme the code will fail eventually. It is caused by that the files/servers are coded to be run from the folder they are in.

So we could either change the readme or the code:

A change in the readme would look like:

Then run from project root:

$ cd server
$ python server.py
$ python weather_station_data_sender.py
$ python client_server.py
$ cd ../client
$ python WeatherAppClient.py

or a code change would look going from, for example this:

DATABASE = "data.json"
HELP = "requests.json"

to this:

DATABASE = "./server/data.json"
HELP = "./server/requests.json"

in every relevant files. What you guys think?

Problems on mac?

Can someone one Linux or windows check if weatherappclient can still talk to the server? or it's a mac problem?

λ python3 WeatherAppClient.py                                                                                                                        ⏎ [3m] ✭
Press Enter to exit
WAclient> get data all
Traceback (most recent call last):
  File "/Users/stale/Skole/oblig1-142/client/WeatherAppClient.py", line 102, in <module>
    get_all_data()
  File "/Users/stale/Skole/oblig1-142/client/WeatherAppClient.py", line 36, in get_all_data
    all_data = get_json("getall")  # loads converts str -> dict
  File "/Users/stale/Skole/oblig1-142/client/WeatherAppClient.py", line 23, in get_json
    _data = json.loads(request_to_server(request))
  File "/Users/stale/Skole/oblig1-142/client/WeatherAppClient.py", line 14, in request_to_server
    size_of_file = int(sock.recv(512).decode())
ValueError: invalid literal for int() with base 10: ''

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.