Skip to content

Commit

Permalink
Added a somewhat working bstats class
Browse files Browse the repository at this point in the history
  • Loading branch information
Thorinwasher committed Apr 9, 2021
1 parent 47dc715 commit 6aef068
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ Logging:
storeUsers: true


debug: false
debug: true
12 changes: 6 additions & 6 deletions pha_bstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
import time
import requests
import uuid
import json

class bstats(threading.Thread):
def __init__(self,plugin_id,is_micropython):
def __init__(self,plugin_id,is_micropython,logger):
threading.Thread.__init__(self)
self.id = plugin_id
self.create_bstat_dictionary()
self.is_micropython = is_micropython
self.logger = logger

def create_bstat_dictionary(self):
arch = architecture()
Expand Down Expand Up @@ -77,10 +77,10 @@ def create_bstat_dictionary(self):
def send_data(self):

url = 'https://bstats.org/submitData/server-implementation'
json_msg = json.dumps(self.bstat_dict)
print(json_msg)
res = requests.post(url, json=json_msg)
print(res.text)
res = requests.post(url, json=self.bstat_dict)
self.logger.debug("Sen message to bstats")
if res.text == "":
pass #TODO idk, some errorprocessing


def run(self):
Expand Down
7 changes: 4 additions & 3 deletions phantom.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pha_yaml import yaml_manager
from pha_bstats import bstats

Version = "0.6.1"
Version = "0.7.0"
defaultConfig = {
"configVersion" : 6,
"serverInfo" : {
Expand Down Expand Up @@ -49,10 +49,11 @@ def __init__(self):

self.is_micropython = config_retriever.is_micropython

plugin_id = 10892
bstats(plugin_id, self.is_micropython).start()

self.logger = logger(Version,self.config)

plugin_id = 10892
bstats(plugin_id, self.is_micropython,self.logger).start()
self.json_creator = json_creator(self.config,self.logger)
self.host = self.config["serverInfo"]["host"]
self.port = self.config["serverInfo"]["port"]
Expand Down

0 comments on commit 6aef068

Please sign in to comment.