Code Monkey home page Code Monkey logo

vulcan-api's People

Contributors

1116574 avatar antoni-czaplicki avatar bdraco avatar capure avatar dependabot[bot] avatar hunterazar avatar kapi2289 avatar kuba2k2 avatar majroch avatar rei-x avatar sourcery-ai-bot avatar v0idzz avatar zaptyp 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

Watchers

 avatar  avatar  avatar

vulcan-api's Issues

Installing using pip throws an error

Environment

Python: 2.7.15rc1
pip: 9.0.1
vulcan-api: 0.2.1

Steps to reproduce

$ pip install vulcan-api

Traceback

running install_egg_info
running egg_info
writing requirements to vulcan_api.egg-info/requires.txt
writing vulcan_api.egg-info/PKG-INFO
writing top-level names to vulcan_api.egg-info/top_level.txt
writing dependency_links to vulcan_api.egg-info/dependency_links.txt
reading manifest file 'vulcan_api.egg-info/SOURCES.txt'
writing manifest file 'vulcan_api.egg-info/SOURCES.txt'
Copying vulcan_api.egg-info to build/bdist.linux-x86_64/wheel/vulcan_api-0.2.1.egg-info
running install_scripts
error: [Errno 2] No such file or directory: 'LICENSE'

----------------------------------------
Failed building wheel for vulcan-api

Vulcan.create throwing error

PyCharm was throwing error at from vulcan import Vulcan saying that it can't find Vulcan in vulcan. I am sure I installed proper vulcan. Because of this I just made quick .py file, but I get error that there is no .create in Vulcan.
Code_fneAIG1T7m
Any ideas? I have no much experience with pycharm/overall python. thanks in advance!

Empty certificate file (null) during register

Hi
I stuck on start with get certificate.
According to documentation:

import vulcan
import json

print(vulcan.version)
certificate = vulcan.Vulcan.register('token', 'symbol', 'pin')
print(certificate)
with open('cert.json', 'w') as f: # You can use other filename
json.dump(certificate, f)

When I run script I have:
Registering...
Registered successfully!
None

File with cert has been created but there is only one word: null.
What I doing wrong.
vulcan-api version :1.0.2 download from pip
python version :Python 3.6.8

Regards

Help with setting up basic project.

Hi! I am new to github/asyncio stuff so I'd love to see some help!
My problem is that I want to create simple application using API. Nothing fancy at all, just connect API and display for example name of student. I tried to set it up using documentation but I failed at registering account. My whole code is

import json
import asyncio
from vulcan import Vulcan
from vulcan import Account
from vulcan import VulcanHebe
from vulcan import Keystore
        
async def main():
    keystore = Keystore.create()
    with open("keystore.json", "w") as f:
        # write a formatted JSON representation
        f.write(keystore.as_json)
    account = Account.register(keystore, "xxx", "xxx", "xxx")
    with open("account.json", "w") as f:
        # write a formatted JSON representation
        f.write(account.as_json)

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

and log says:

Generating key pair...
Getting Firebase token...
Generated for Vulcan API (Python 3.8.6), sha1: x
Traceback (most recent call last):
  File "c:\Users\PC\Desktop\main.py", line 20, in <module>
    loop.run_until_complete(main())
  File "C:\Users\PC\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "c:\Users\PC\Desktop\main.py", line 16, in main
    f.write(account.as_json)
AttributeError: 'coroutine' object has no attribute 'as_json'
sys:1: RuntimeWarning: coroutine 'Account.register' was never awaited

I have no idea why(keystore is generating correctly I am pretty sure), and help would be greatly appreciated!

Reading messages

Hey! Is it possible to get all student's messages? I would like to get all unread messages, loop through them and then mark as read. Thanks in advance!

Internal Server Error -- cannot use library at all

The following code worked a few months back

import asyncio
from vulcan import Keystore, Account, Vulcan

# Loading keystore & account
with open("keystore.json") as f:
    keystore = Keystore.load(f)

with open("account.json") as f:
    account = Account.load(f)


async def main():
    # Client creation
    client = Vulcan(keystore=keystore, account=account)
    await client.select_student()  # select the first available student
    print(client.student)
    await client.close()


if __name__ == "__main__":
    asyncio.run(main())

When trying to run it now, I get the following error

Traceback (most recent call last):
  File "D:\coding-projects\python\vulcan-marks\main.py", line 21, in <module>
    asyncio.run(main())
  File "C:\Users\Kwiecinski\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\Kwiecinski\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "D:\coding-projects\python\vulcan-marks\main.py", line 16, in main
    await client.select_student()  # select the first available student
  File "D:\coding-projects\python\vulcan-marks\venv\lib\site-packages\vulcan\_client.py", line 42, in select_student
    students = await self.get_students()
  File "D:\coding-projects\python\vulcan-marks\venv\lib\site-packages\vulcan\_client.py", line 61, in get_students
    self._students = await Student.get(self._api)
  File "D:\coding-projects\python\vulcan-marks\venv\lib\site-packages\vulcan\model\_student.py", line 78, in get
    data = await api.get(STUDENT_LIST, **kwargs)
  File "D:\coding-projects\python\vulcan-marks\venv\lib\site-packages\vulcan\_api.py", line 155, in get
    return await self._request("GET", url, body=None, **kwargs)
  File "D:\coding-projects\python\vulcan-marks\venv\lib\site-packages\vulcan\_api.py", line 142, in _request
    raise RuntimeError(status["Message"])
RuntimeError: Internal Server Error (ArgumentException)
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x00000184CA106910>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x00000184CA0E96A0>, 158185.046)]']
connector: <aiohttp.connector.TCPConnector object at 0x00000184CA106940>
Fatal error on SSL transport
protocol: <asyncio.sslproto.SSLProtocol object at 0x00000184CA1183D0>
transport: <_ProactorSocketTransport fd=868 read=<_OverlappedFuture cancelled>>
Traceback (most recent call last):
  File "C:\Users\Kwiecinski\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 684, in _process_write_backlog
    self._transport.write(chunk)
  File "C:\Users\Kwiecinski\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 359, in write
    self._loop_writing(data=bytes(data))
  File "C:\Users\Kwiecinski\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 395, in _loop_writing
    self._write_fut = self._loop._proactor.send(self._sock, data)
AttributeError: 'NoneType' object has no attribute 'send'
Exception ignored in: <function _SSLProtocolTransport.__del__ at 0x00000184C8472430>
Traceback (most recent call last):
  File "C:\Users\Kwiecinski\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 321, in __del__
  File "C:\Users\Kwiecinski\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 316, in close
  File "C:\Users\Kwiecinski\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 593, in _start_shutdown
  File "C:\Users\Kwiecinski\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 598, in _write_appdata
  File "C:\Users\Kwiecinski\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 706, in _process_write_backlog
  File "C:\Users\Kwiecinski\AppData\Local\Programs\Python\Python39\lib\asyncio\sslproto.py", line 720, in _fatal_error
  File "C:\Users\Kwiecinski\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 151, in _force_close
  File "C:\Users\Kwiecinski\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 746, in call_soon
  File "C:\Users\Kwiecinski\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
RuntimeError: Event loop is closed

I'm really unsure what the issue could be.

cannot import name 'Vulcan' from 'vulcan'

Hej, poległem szybko, bo już na importowaniu tego pakietu.

import json
import requests
from vulcan import Vulcan

print("here")

Logi:

Traceback (most recent call last):
  File "vulcan.py", line 3, in <module>
    from vulcan import Vulcan
  File "/Users/bartekpacia/dev/python/vulcan/vulcan.py", line 3, in <module>
    from vulcan import Vulcan
ImportError: cannot import name 'Vulcan' from 'vulcan'

Naprawdę nie wiem co robię źle, pakiet oczywiście zainstalowany przez PIPa. Moduł jest importoway, ale chyba po prostu nie umie znaleźć klasy Vulcan

pomocy

TypeError: Object of type Certificate is not JSON serializable

When trying to register using this code:

from vulcan import Vulcan
import json

certificate = Vulcan.register('token, 'symbol', 'pin')

with open('cert.json', 'w') as f: # You can use other filename
    json.dump(certificate, f)

i get this error:

(venv) n3rsti@n3rsti:~/repo/vulcan$ python3 register.py
Registering...
Registered successfully!
Traceback (most recent call last):
File "register.py", line 7, in
json.dump(certificate, f)
File "/usr/lib/python3.7/json/init.py", line 179, in dump
for chunk in iterable:
File "/usr/lib/python3.7/json/encoder.py", line 438, in _iterencode
o = _default(o)
File "/usr/lib/python3.7/json/encoder.py", line 179, in default
raise TypeError(f'Object of type {o.class.name} '
TypeError: Object of type Certificate is not JSON serializable

Error with converting cert to Certificate model

cert = open("cert.json").read()

Error when using Vulcan(cert).get_grades() with certificate as str:

Traceback (most recent call last):
  File "xyz", line 34, in <module>
    print(Vulcan(cert).get_grades())
  File "xyz\vulcan\_vulcan.py", line 25, in __init__    self._api = Api(certificate)
  File "xyz\vulcan\_api.py", line 14, in __init__   
    self.cert = to_model(Certificate, certificate)
  File "xyz\related\functions.py", line 107, in to_model
    value = cls(value)
TypeError: __init__() missing 3 required positional arguments: 'key', 'key_formatted', and 'base_url'

When I'm using Vulcan(json.loads(cert)) there's no error, but there's no output too:

print("[*] print(Vulcan(json.loads(cert)).get_grades())")
print(Vulcan(json.loads(cert)).get_grades())

print("[*] Vulcan(json.loads(cert)).get_grades()")
Vulcan(json.loads(cert)).get_grades()

Output:

[*] print(Vulcan(json.loads(cert)).get_grades())
<generator object Grade.get at 0x000001B9416BDF48>
[*] Vulcan(json.loads(cert)).get_grades()

simplejson.errors.JSONDecodeError

Hi. I have been trying to get certificate from server as described in README:
certificate = Vulcan.register('', '', '')

but I am getting 400 Bad Request error from request library:

File "/usr/local/lib/python3.6/dist-packages/vulcan/_vulcan.py", line 57, in register
return Certificate.get(token, symbol, pin)
File "/usr/local/lib/python3.6/dist-packages/vulcan/_certificate.py", line 56, in get
j = r.json()
File "/home/pawel/.local/lib/python3.6/site-packages/requests/models.py", line 897, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3/dist-packages/simplejson/init.py", line 518, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).en

I tested 3 different sets of tokens/symbols, tried changing 'DeviceSystemType' to Android in the header or pulling new version but I still get the same error.
Any ideas?

JSON parser crash while fetching "-" (dash sign) from register

Traceback (most recent call last):
  File "D:\Python\lib\site-packages\vulcan\_vulcan.py", line 152, in _request
    return r.json()
  File "D:\Python\lib\site-packages\requests\models.py", line 897, in json
    return complexjson.loads(self.text, **kwargs)
  File "D:\Python\lib\json\__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "D:\Python\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "D:\Python\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\rafal\Documents\py-dzienniczek\main.py", line 20, in <module>
    klient.ustaw_ucznia(uczen)
  File "D:\Python\lib\site-packages\vulcan\_vulcan.py", line 189, in ustaw_ucznia
    self._dict = self._get_dict()
  File "D:\Python\lib\site-packages\vulcan\_vulcan.py", line 165, in _get_dict
    j = self._post("Uczen/Slowniki")
  File "D:\Python\lib\site-packages\vulcan\_vulcan.py", line 162, in _post
    return self._request("POST", endpoint, json=json, as_json=as_json, **kwargs)
  File "D:\Python\lib\site-packages\vulcan\_vulcan.py", line 154, in _request
    raise VulcanAPIException("Wystąpił błąd.")
vulcan._utils.VulcanAPIException: Wystąpił błąd.

Error occured while downloading grades data. Error ocurrs when student has a "-" (dash sign) in grades.

data.get_homework() returns invalid attachments

When I'm trying to fetch attachments from homework it returns lists that look like this:
[['Name', 'Link'], ['Name', 'Link'], ['Name', 'Link'], ['Name', 'Link'], ['Name', 'Link']]
Is it possible to get proper links to attachments?
code

Require to pass firebase token while registering client.

Now it's require to pass firebase token while POSTing to https://lekcjaplus.vulcan.net.pl/<symbol>/mobile-api/Uczen.v3.UczenStart/Certyfikat.

Example

{
	"RequestId": "9b9e7b4c-3c63-459d-9557-99494c155cb4",
	"TimeKey": 1590145061,
	"RemoteMobileTimeKey": 1590145061,
	"RemoteMobileAppVersion": "20.4.1.358",
	"RemoteMobileAppName": "VULCAN-iOS-ModulUcznia",
	"AppVersion": "20.4.1.358",
	"DeviceId": "77c8816a-c9d8-4f81-9e34-ff371528dd00",
	"DeviceName": "iPhone",
	"DeviceNameUser": "iPhone (Krystian)",
	"DeviceDescription": "Best Phone Ever",
	"DeviceSystemType": "iOS",
	"DeviceSystemVersion": "13.5",
	"TokenKey": "<hidden>",
	"PIN": "<hidden>",
	"FirebaseTokenKey": "<hidden>:<hidden>-G25Fry6T0cZ8ELJC8iM_Ck6w-Jh-JJWibse-Ja"
}

`AttributeError: 'NoneType' object has no attribute 'get'` on `klient.oceny()`

When trying to call klient.oceny(), Python 3.7 throws this error:

(...)\site-packages\vulcan\_grade.py", line 27, in from_json
    id = j.get("Id")
AttributeError: 'NoneType' object has no attribute 'get'

When trying to debug this, the problem lies in _vulcan.py file, in oceny(self) function - in the return:

return list(map(lambda x: Ocena.from_json(x), oceny))

The whole ocena object is good, the problem lies in the return statement. Unfortunately, I'm not that experienced in python, so I can't really fix it myself (but I will try anyways :P)

Reading messages in new api

Hi, i wanted to handle reading message like it was in old api but it seems that the new one has missing that feature.
Are there any progress in implementing messages handling at this time? What's the estimated time of releasing?

TypeError: ("'second_name' must be (<class 'str'>,) (got None that is a <class 'NoneType'>).")

When I'm trying to initialize Vulcan object by client = Vulcan(certificate), error is raised that "second_name" is None, which is true. When I add student['Imie2'] = "" in Student class in get method, everything works as expected.

  def get(cls, api):
      j = api.post(api.base_url + "UczenStart/ListaUczniow")
  
      for student in j.get("Data", []):
          student['Imie2'] = ""
          yield to_model(cls, cls.format_json(student))

How to get presence percentages

I'm wondering how to get the actual frequency of the user per subject, I haven't found anything in the documentation. I thought that get_attendance() would give me what I want, but that's not really the case, (I'm unsure what it does if I'm honest with you, I'm guessing it returns the attendance in the given day?)

If anyone could point me in the right direction or implement this feature it'd be amazing.

Pozdrawiam :)

Async branch

I have created fork of this api and replaced requests library with aiohttp to increase performance and get away with GIL related issues.

Major changes:

  • Methods are now coroutines (requires an await keyword to run)
  • Vulcan.__init__() can't be a coroutine, so initialisation is done by coroutine async Vulcan.create(certificate, logging_level=None)

Could you create async branch?

Fork is here
Real use examples are here

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.