linkaFederations 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,48 @@
1
+ # Qt / CMake / Build folders
2
+ cross-plataform/build/
3
+ cross-plataform/json/
4
+ cross-plataform/third-party/
5
+ backend/DB/
6
+ build-*/
7
+ build/
8
+ debug/
9
+ release/
10
+ cmake-build-*/
11
+ node_modules/
12
+ __pycache__/
13
+ *.pyc
14
+ venv/
15
+ # Qt Creator / user files
16
+ *.pro.user
17
+ *.user
18
+ *.user.*
19
+ *.autosave
20
+ *.qmlproject.user*
21
+ *.env
22
+ # Makefiles gerados
23
+ Makefile
24
+ Makefile.*
25
+ *.make
26
+
27
+ # CMake
28
+ CMakeCache.txt
29
+ CMakeFiles/
30
+ cmake_install.cmake
31
+ compile_commands.json
32
+ backend/5.15.2/
33
+ # Android Qt build
34
+ android-build/
35
+ *.apk
36
+ *.aab
37
+ *.so
38
+ *.db
39
+ # Objetos compilados
40
+ *.o
41
+ *.obj
42
+ *.lo
43
+ *.a
44
+ *.lib
45
+ *.dll
46
+ *.exe
47
+ *.keystore
48
+ *.out
@@ -0,0 +1,12 @@
1
+ Metadata-Version: 2.4
2
+ Name: linkaFederations
3
+ Version: 0.1.0
4
+ Summary: linkaFederations is a linka-lib for manage in a easy way the federations
5
+ Author-email: Luiz Gustavo <luizsgustavo76@gmail.com>
6
+ Classifier: License :: OSI Approved :: MIT License
7
+ Classifier: Operating System :: OS Independent
8
+ Classifier: Programming Language :: Python :: 3
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+
12
+ # LinkaFederations SDK
@@ -0,0 +1 @@
1
+ # LinkaFederations SDK
@@ -0,0 +1,23 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "linkaFederations"
7
+ version = "0.1.0"
8
+ authors = [
9
+ { name="Luiz Gustavo", email="luizsgustavo76@gmail.com" },
10
+ ]
11
+ description = "linkaFederations is a linka-lib for manage in a easy way the federations"
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ dependencies = [
20
+ ]
21
+
22
+ [tool.hatch.build.targets.wheel]
23
+ packages = ["src/linkaFederations"]
@@ -0,0 +1 @@
1
+ from .linkaFederations import LinkaFederations
@@ -0,0 +1,73 @@
1
+ import requests
2
+ import sqlite3
3
+
4
+ class LinkaFederations:
5
+ def __init__(self, db_path="slug-cache.db"):
6
+ self.db_path = db_path
7
+ self.slugs_pre_loaded = {}
8
+ self.create_db()
9
+ self.load_slugs()
10
+
11
+ def get_db(self):
12
+ return sqlite3.connect(self.db_path)
13
+
14
+ def create_db(self):
15
+ conn = self.get_db()
16
+ cur = conn.cursor()
17
+ cur.execute("""
18
+ CREATE TABLE IF NOT EXISTS slug_cache (
19
+ slug TEXT UNIQUE,
20
+ url TEXT
21
+ )
22
+ """)
23
+ conn.commit()
24
+ conn.close()
25
+
26
+ def load_slugs(self):
27
+ conn = self.get_db()
28
+ cur = conn.cursor()
29
+ cur.execute("SELECT slug, url FROM slug_cache")
30
+ result = cur.fetchall()
31
+ conn.close()
32
+
33
+ for slug, url in result:
34
+ self.slugs_pre_loaded[slug] = url
35
+ def receiveConnection(self, slug_or_url):
36
+ if slug_or_url in self.slugs_pre_loaded:
37
+ target_url = self.slugs_pre_loaded[slug_or_url]
38
+ else:
39
+ target_url = slug_or_url
40
+ try:
41
+ response = requests.get(target_url, timeout=10)
42
+ print(response.json())
43
+ except Exception as e:
44
+ print(f"fatal error {e}")
45
+ def sendPayload(self, payload, slug_or_url, headers):
46
+ if slug_or_url in self.slugs_pre_loaded:
47
+ target_url = self.slugs_pre_loaded[slug_or_url]
48
+ else:
49
+ target_url = slug_or_url
50
+
51
+ try:
52
+ if headers:
53
+ response = requests.post(
54
+ target_url,
55
+ json=payload,
56
+ headers=headers,
57
+ timeout=10
58
+ )
59
+ else:
60
+ response = requests.post(
61
+ target_url,
62
+ json=payload,
63
+ timeout=10
64
+ )
65
+ if response.status_code in [200, 201]:
66
+ return response
67
+ else:
68
+ print(f"[Linka] Error in instance response: {response.status_code}")
69
+ return None
70
+
71
+ except requests.exceptions.RequestException as e:
72
+ print(f"[Linka] Fatal error to connect: {e}")
73
+ return None