Skip to content

Commit

Permalink
feat: ✨ fetch projects directly from BOINC
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre CORBEL authored and pcorbel committed Sep 17, 2021
1 parent 5850b19 commit c2e1a65
Show file tree
Hide file tree
Showing 21 changed files with 190 additions and 473 deletions.
7 changes: 1 addition & 6 deletions agent/app/app.py
@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-

import os
import time
from dataclasses import dataclass

import schedule
import yaml # type: ignore
from balena.operator import Operator as Balena
from boinc.operator import Operator as Boinc
from scitizen.operator import Operator as Scitizen
Expand Down Expand Up @@ -35,10 +33,7 @@ def __post_init__(self) -> None:
Seed the project table, check the hostname, set the schedule interval and
run the agent
"""
with open(f"{os.path.dirname(os.path.abspath(__file__))}/projects.yml") as file:
projects = yaml.load(file, Loader=yaml.SafeLoader).get("projects")
self.scitizen.set_projects(projects)

self.scitizen.set_projects()
self.balena.set_hostname("scitizen")

schedule.every(30).seconds.do(self.job)
Expand Down
34 changes: 21 additions & 13 deletions agent/app/boinc/operator.py
Expand Up @@ -7,7 +7,7 @@
from pathlib import Path
from typing import Any, Dict, List

import boinc.utils as utils
import utils
from jinja2 import Template
from xmltodict import parse

Expand Down Expand Up @@ -274,8 +274,8 @@ def get_host_info(self) -> Dict[str, Any]:
host: dict = {}

# fetch data from the BOINC client and parse it
reply = self._send_request(name="get_host_info")
result = utils.deep_get(reply, "boinc_gui_rpc_reply.host_info")
reply = self._send_request(name="get_state")
result = utils.deep_get(reply, "boinc_gui_rpc_reply.client_state.host_info")

# hack to handle no results
if result is None:
Expand Down Expand Up @@ -305,20 +305,28 @@ def get_host_info(self) -> Dict[str, Any]:
host.update({"domain_name": result.get("domain_name")})

# fetch data from the BOINC client and parse it
reply = self._send_request(name="exchange_versions")
result = utils.deep_get(reply, "boinc_gui_rpc_reply.server_version")

# hack to handle no results
if result is None:
result = {}
major = utils.deep_get(
reply, "boinc_gui_rpc_reply.client_state.core_client_major_version"
)
minor = utils.deep_get(
reply, "boinc_gui_rpc_reply.client_state.core_client_minor_version"
)
release = utils.deep_get(
reply, "boinc_gui_rpc_reply.client_state.core_client_release"
)

# add static data relative to the software
host.update(
{
"boinc_version": f"{result.get('major')}.{result.get('minor')}.{result.get('release')}"
}
host.update({"boinc_version": f"{major}.{minor}.{release}"})

# fetch data from the BOINC client and parse it
reply = self._send_request(name="get_state")
platform = utils.deep_get(
reply, "boinc_gui_rpc_reply.client_state.platform_name"
)

# add static data relative to the software
host.update({"platform": platform})

return host

def sync_projects(self, projects: List[Dict[str, Any]]) -> None:
Expand Down
3 changes: 0 additions & 3 deletions agent/app/boinc/queries/exchange_versions.xml.j2

This file was deleted.

@@ -1,3 +1,3 @@
<boinc_gui_rpc_request>
<get_host_info />
<get_state />
</boinc_gui_rpc_request>

0 comments on commit c2e1a65

Please sign in to comment.