Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

updates #5

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions .vscode/wallet.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"folders": [
{
"path": "../hermes"
},
{
"path": "../angelia"
},
{
"path": "../gitops"
},
{
"path": "../metis"
},
{
"path": "../pelops"
},
{
"path": "."
},
{
"path": "../midas"
},
{
"path": "../wallet-retry-lib"
},
{
"path": "../api-reflector"
},
{
"path": "../bank-tools"
}
],
"settings": {
"terminal.integrated.shellIntegration.history": 100000,
"files.autoSave": "onFocusChange",
"dotenv.enableAutocloaking": false,
"[python]": {
"editor.formatOnSave": true,
"diffEditor.ignoreTrimWhitespace": false,
"editor.formatOnType": true,
"editor.wordBasedSuggestions": false,
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
},
"black-formatter.args": [
"--line-length=120",
],
"isort.args": [
"--profile",
"black"
],
"python.linting.mypyEnabled": false,
"ruff.organizeImports": true,
"ruff.args": [
"--line-length=120"
]
},
"launch": {
"version": "0.2.0",
"configurations": [
{
"name": "Launch config template", // The launch config can be inside /workspace-project/.vscode too
"consoleTitle": "Celery Worker", // This name has to matched in the compounds below
"type": "python",
"request": "launch",
"module": "commands",
"args": [
"celery command"
],
"justMyCode": false
}
],
"compounds": [
{
"name": "Wallet stack",
"configurations": [
"Celery Worker",
"Celery Beat",
"Hermes APIv1",
"Hermes api-messaging",
"Angelia Gunicorn"
],
"stopAll": true,
"presentation": {
"hidden": false,
"group": "",
"order": 1
}
},
{
"name": "Wallet + Midas + API Reflector",
"configurations": [
"Celery Worker",
"Celery Beat",
"Hermes APIv1",
"Hermes api-messaging",
"Angelia Gunicorn",
"Midas",
"API Reflector",
],
"stopAll": true,
"presentation": {
"hidden": false,
"group": "",
"order": 2
}
}
]
}
}
61 changes: 32 additions & 29 deletions Fidas/Fallbackr.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#
#
# Fallbackr
#
# Fake Midas callbacks to hermes
# (I would NOT use the tkinter GUI!)
#
#
"""

Fallbackr

Fake Midas callbacks to hermes
(I would NOT use the tkinter GUI!)

"""

import sys
import tkinter as tk
from enum import IntEnum
from tkinter.scrolledtext import ScrolledText
from tkinter.ttk import Combobox
from tkinter import *
import sys

import requests

Expand Down Expand Up @@ -65,9 +65,11 @@ def update_status(
scheme_account_id,
journey=JourneyTypes.UPDATE,
status=SchemeAccountStatus.ACTIVE,
user_info={},
server=HERMES
user_info=None,
server=HERMES,
):
if user_info is None:
user_info = {}
print(f"**** Fallbacker called for scheme account {scheme_account_id} ****")

url = f"{server}/schemes/accounts/{scheme_account_id}/status"
Expand All @@ -79,7 +81,7 @@ def update_status(
"Content-type": "application/json",
"transaction": "success",
"User-agent": "Midas on localhost",
"Authorization": "token " + SERVICE_API_KEY,
"Authorization": f"token {SERVICE_API_KEY}",
}
response = requests.request("POST", url, json=payload, headers=headers)
print(f"**** Hermes called for scheme account {scheme_account_id} ****")
Expand Down Expand Up @@ -110,7 +112,7 @@ def join_fail(slub, user):
"Content-type": "application/json",
"transaction": "join_error",
"User-agent": "Midas on localhost",
"Authorization": "token " + SERVICE_API_KEY,
"Authorization": f"token {SERVICE_API_KEY}",
}
response = requests.request("POST", url, json=payload, headers=headers)

Expand All @@ -126,36 +128,36 @@ def join(slub, user):
"Content-type": "application/json",
"transaction": "success",
"User-agent": "Midas on localhost",
"Authorization": "token " + SERVICE_API_KEY,
"Authorization": f"token {SERVICE_API_KEY}",
}

response = requests.request("POST", url, json=payload, headers=headers)

return response.json(), response.status_code


class Fallbackr(Tk):
class Fallbackr(tk.Tk):
def __init__(self):
Tk.__init__(self)
tk.Tk.__init__(self)
self.title("Fallbackr")
self.geometry("600x400")
lf = LabelFrame(self, text="Server")

lf = tk.LabelFrame(self, text="Server")
lf.pack(fill="x")
self.server = StringVar()
self.server = tk.StringVar()
server = Combobox(lf, textvariable=self.server, values=SERVERS)
server.pack(fill="x")
self.server.set(HERMES)
lf = LabelFrame(self, text="Scheme Account ID")

lf = tk.LabelFrame(self, text="Scheme Account ID")
lf.pack(fill="x")
self.scheme_account_id = StringVar()
server = Entry(lf, textvariable=self.scheme_account_id)
self.scheme_account_id = tk.StringVar()
server = tk.Entry(lf, textvariable=self.scheme_account_id)
server.pack(fill="x")
b = Button(self, text="Active", command=self.active_status)

b = tk.Button(self, text="Active", command=self.active_status)
b.pack()
b = Button(self, text="Invalid Credentials", command=self.invalid_status)
b = tk.Button(self, text="Invalid Credentials", command=self.invalid_status)
b.pack()

self.loggee = ScrolledText(self, wrap="none")
Expand All @@ -164,9 +166,9 @@ def __init__(self):

def write(self, *stuff):
for line in stuff:
self.loggee.insert("end", line+"\n")
self.loggee.insert("end", line + "\n")
self.loggee.see("end")

def flush(self, *stuff):
pass

Expand All @@ -180,6 +182,7 @@ def invalid_status(self):
server = self.server.get()
update_status(id, server=server, status=SchemeAccountStatus.INVALID_CREDENTIALS)


if __name__ == "__main__":
# in your CLIENT code when you perform a PATCH Auth request (for example)
# and normally Midas sends a request back to Hermes just
Expand Down
Loading