I requesting this endpoint https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=XXX&steamids=76561198049710886
And I'm getting this reply:
{
"response":{
"players":[
{
"steamid":"76561198049710886",
"communityvisibilitystate":3,
"profilestate":1,
"personaname":"testing",
"lastlogoff":1570961241,
"profileurl":"https://steamcommunity.com/id/danpool/",
"avatar":"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/1b/1b5db030143e6110de8558adf4235ece591ddde1.jpg",
"avatarmedium":"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/1b/1b5db030143e6110de8558adf4235ece591ddde1_medium.jpg",
"avatarfull":"https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/1b/1b5db030143e6110de8558adf4235ece591ddde1_full.jpg",
"personastate":0,
"realname":"John Doe",
"primaryclanid":"103582791429521408",
"timecreated":1317282093,
"personastateflags":0,
"loccountrycode":"NO"
}
]
}
}
But i'm confused what personastateflags means, I find some stuff by searching for it but they all different and official docs don't have any information about it.
last one i found is this one:
1: 'Offline', 2: 'Online', 4: 'Golden',
64: 'Online using Big Picture',
256: 'Online using Web Client',
512: 'Online using Mobile',
1024: 'Online using Steam Controller'
but personastateflags is 0 in most cases so it doesn't make any sense :/
I also tried to launching big picture mode while I was online, and result was "1024" which would be "Online using Steam Controller" and not correct.
P.S.
I successfully converted personastate using this object
0: 'Offline', 1: 'Online', 2: 'Busy',
3: 'Away', 4: 'Snooze', 5 :'Looking to Trade',
6: 'Looking to Play'
I have not read into steam docs, but it should mean that the user is offline.
Here is what docs say:
The user's current status. 0 - Offline, 1 - Online, 2 - Busy, 3 - Away, 4 - Snooze, 5 - looking to trade, 6 - looking to play. If the player's profile is private, this will always be "0", except is the user has set their status to looking to trade or looking to play, because a bug makes those status appear even if the profile is private.
Related
I have a dash python web application and I would like to restrict the access of this application to a single user at a given point in time. How can I achieve that? Is there a way to get an event when a second user tries to access it?
I've implemented something similar some time ago.
Basically, i changed the rendered layout, based on time conditions.
For my case, i wanted to make my app working within working hours. ( from 08:00 to 19:00).
#app.callback(Output("page-content", "children"), [Input("url", "pathname")])
def render_page_content(pathname):
# ---------------------------------------------------
if pathname == "/":
# define working time for MILF services
day_of_week = date.today().strftime("%A")
now = datetime.datetime.now()
working_days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
if day_of_week in working_days and (now.hour >= 8) and (now.hour < 19):
# if working time is ok, render App page
layout = html.Div([tab01.layout])
else:
# if working time is closed, render an Info Page
layout = dcc.Markdown('''
### APP is not working now... See you soon !
###### Opening time : Monday - Friday
###### Opening hours : 08:00 - 19:00
'''),
return layout
When conditions are not met, i print the message : "APP is not working now... See you soon !"
So, I am writing a program in Python to fetch data from google classroom API using requests module. I am getting the full json response from the classroom as follows :
{'announcements': [{'courseId': '#############', 'id': '###########', 'text': 'This is a test','state': 'PUBLISHED', 'alternateLink': 'https://classroom.google.com/c/##########/p/###########', 'creationTime': '2021-04-11T10:25:54.135Z', 'updateTime': '2021-04-11T10:25:53.029Z', 'creatorUserId': '###############'}, {'courseId': '############', 'id': '#############', 'text': 'Hello everyone', 'state': 'PUBLISHED', 'alternateLink': 'https://classroom.google.com/c/#############/p/##################', 'creationTime': '2021-04-11T10:24:30.952Z', 'updateTime': '2021-04-11T10:24:48.880Z', 'creatorUserId': '##############'}, {'courseId': '##################', 'id': '############', 'text': 'Hello everyone', 'state': 'PUBLISHED', 'alternateLink': 'https://classroom.google.com/c/##############/p/################', 'creationTime': '2021-04-11T10:23:42.977Z', 'updateTime': '2021-04-11T10:23:42.920Z', 'creatorUserId': '##############'}]}
I was actually unable to convert this into a pretty format so just pasting it as I got it from the http request. What I actually wish to do is just request the first few announcements (say 1, 2, 3 whatever depending upon the requirement) from the service while what I'm getting are all the announcements (as in the sample 3 announcements) that had been made ever since the classroom was created. Now, I believe that fetching all the announcements might make the program slower and so I would prefer if I could get only the required ones. Is there any way to do this by passing some arguments or anything? There are a few direct functions provided by google classroom however I came across those a little later and have already written everything using the requests module which would require changing a lot of things which I would like to avoid. However if unavoidable I would go that route as well.
Answer:
Use the pageSize field to limit the number of responses you want in the announcements: list request, with an orderBy parameter of updateTime asc.
More Information:
As per the documentation:
orderBy: string
Optional sort ordering for results. A comma-separated list of fields with an optional sort direction keyword. Supported field is updateTime. Supported direction keywords are asc and desc. If not specified, updateTime desc is the default behavior. Examples: updateTime asc, updateTime
and:
pageSize: integer
Maximum number of items to return. Zero or unspecified indicates that the server may assign a maximum.
So, let's say you want the first 3 announcements for a course, you would use a pageSize of 3, and an orderBy of updateTime asc:
# Copyright 2021 Google LLC.
# SPDX-License-Identifier: Apache-2.0
service = build('classroom', 'v1', credentials=creds)
asc = "updateTime asc"
pageSize = 3
# Call the Classroom API
results = service.courses().announcements().list(pageSize=3, orderBy=asc ).execute()
or an HTTP request example:
GET https://classroom.googleapis.com/v1/courses/[COURSE_ID]/announcements
?orderBy=updateTime%20asc
&pageSize=2
&key=[YOUR_API_KEY] HTTP/1.1
Authorization: Bearer [YOUR_ACCESS_TOKEN]
Accept: application/json
References:
Method: announcements.list | Classroom API | Google Developers
This is the snippet of my code where I am sending a payload to a slack webhook:
dictoftitle = {i: posts_to_print[i] for i in range(0, len(posts_to_print))}
response = requests.post(web_hook_url, data=json.dumps(dictoftitle))
if response.status_code != 200:
raise ValueError('Request to slack returned an error %s, the response is:\n%s '%
(response.status_code, response.text) )
This is how the payload looks like:
print(dictoftitle)
{0: 'When girls are the shero of the story', 1: 'Simplified global game management: Introducing Game Servers', 2: 'Google Cloud named a leader in the Forrester Wave for Public Cloud Development and Infrastructure Platforms', 3: "Modernizing Twitter's ad engagement analytics platform", 4: 'Protect users in your apps with
multi-factor authentication', 5: 'Postponing Google Cloud Next ’20: Digital Connect', 6: 'Not just for HTTP anymore: gRPC comes to Cloud Run', 7: 'Data processing just got easier with Apps Script’s new V8 runtime', 8: 'G Suite Pro Tips: Declutter your inbox with Gmail filters', 9: 'How EBSCO delivers dynamic research services with Apigee', 10: 'Finding a problem at the bottom of the Google stack', 11: 'Best practices for Chrome Enterprise admins to enable a remote workforce', 12: 'Modern analytics made easy with new Redshift, S3 migration tools', 13: 'Local SSDs + VMs = love at first (tera)byte', 14: '재택근무 시 업무 수행과 관련된 8가
지 도움말', 15: '使用 G Suite 居家办公的八大妙招', 16: '善用 8 大秘訣,確保在家工作時的工作效率', 17: '8 tips untuk menyelesaikan pekerjaan saat bekerja dari jarak jauh', 18: '8 mẹo để hoàn thành công việc khi làm việc tại nhà', 19: 'เคลดลบ 8 ข้อเพ่อการทำงานจากบ้านอย่างมประสทธภาพ'}
I am getting an error when sending the payload :
Traceback (most recent call last):
File "test3.py", line 83, in <module>
raise ValueError('Request to slack returned an error %s, the response is:\n%s '% (response.status_code, response.text) )
ValueError: Request to slack returned an error 400, the response is:
missing_text_or_fallback_or_attachments
Do you have any idea on what is causing the issue?
You're trying to use a generic Slack incoming webhook with a service that sends a custom payload right? You will need to transform their payload into the format that's accepted by the Slack incoming webhooks (https://api.slack.com/messaging/composing). I hope that makes sense. Let us know if you have any further questions about this.
Artillery: How to run the scenarios sequentially and also display the results of each scenario in the same file?
I'm currently writing nodejs test with artillery.io to compare performance between two endpoints that I implemented. I defined two scenarios and I would like to get the result of each in a same report file.
The execution of the tests is not sequential, it means that at the end of the test I have a result already combined and impossible to know the performance of each one but for all.
config:
target: "http://localhost:8080/api/v1"
plugins:
expect: {}
metrics-by-endpoint: {}
phases:
- duration: 60
arrivalRate: 2
environments:
dev:
target: "https://backend.com/api/v1"
phases:
- duration: 60
arrivalRate: 2
scenarios:
- name: "Nashhorn"
flow:
- post:
url: "/casting/nashhorn"
auth:
user: user1
pass: user1
json:
body:
fromFile: "./casting-dataset-01-as-input.json"
options:
filename: "casting_dataset"
conentType: "application/json"
expect:
statusCode: 200
capture:
regexp: '[^]*'
as: 'result'
- log: 'result= {{result}}'
- name: "Nodejs"
flow:
- post:
url: "/casting/nodejs"
auth:
user: user1
pass: user1
json:
body:
fromFile: "./casting-dataset-01-as-input.json"
options:
filename: "casting_dataset"
conentType: "application/json"
expect:
statusCode: 200
capture:
regexp: '[^]*'
as: 'result'
- log: 'result= {{result}}'
How to run the scenarios sequentially and also display the results of each scenario in the same file?
Thank you in advance for your answers
I think you miss the param weight, this param defines de probability to execute the scenario. if in you first scenario put a weight of 1 and in the second put the same value, both will have the same probability to been execute (50%).
If you put in the first scenario a weight of 3 and in the second one a weight of 1, the second scenario will have a 25% probability of execution while the first one will have a 75% probability of being executed.
This combined with the arrivalRate parameter and setting the value of rampTo to 2, will cause 2 scenarios to be executed every second, in which if you set a weight of 1 to the two scenarios, they will be executed at the same time.
Look down for scenario weights in the documentation
scenarios:
- flow:
- log: Scenario for GET requests
- get:
url: /v1/url_test_1
name: Scenario for GET requests
weight: 1
- flow:
- log: Scenario for POST requets
- post:
json: {}
url: /v1/url_test_2
name: Scenario for POST
weight: 1
I hope this helps you.
To my knowledge, there isn't a good way to do this with the existing the artillery logic.
using this test script:
scenarios:
- name: "test 1"
flow:
- post:
url: "/postman-echo.com/get?test=123"
weight: 1
- name: "test 2"
flow:
- post:
url: "/postman-echo.com/get?test=123"
weight: 1
... etc...
Started phase 0 (equal weight), duration: 1s # 13:21:54(-0500) 2021-01-06
Report # 13:21:55(-0500) 2021-01-06
Elapsed time: 1 second
Scenarios launched: 20
Scenarios completed: 20
Requests completed: 20
Mean response/sec: 14.18
Response time (msec):
min: 117.2
max: 146.1
median: 128.6
p95: 144.5
p99: 146.1
Codes:
404: 20
All virtual users finished
Summary report # 13:21:55(-0500) 2021-01-06
Scenarios launched: 20
Scenarios completed: 20
Requests completed: 20
Mean response/sec: 14.18
Response time (msec):
min: 117.2
max: 146.1
median: 128.6
p95: 144.5
p99: 146.1
Scenario counts:
test 7: 4 (20%)
test 5: 2 (10%)
test 3: 1 (5%)
test 1: 4 (20%)
test 9: 2 (10%)
test 8: 3 (15%)
test 10: 2 (10%)
test 4: 1 (5%)
test 6: 1 (5%)
Codes:
404: 20
So basically you can see that they are weighted equally, but are not running equally. So I think there needs to be something added to the code itself for artillery. Happy to be wrong here.
You can use the per endpoint metrics plugin to give you the results per endpoint instead of aggregated.
https://artillery.io/docs/guides/plugins/plugin-metrics-by-endpoint.html
I see you already have this in your config, but it cannot be working if it is not giving you what you need. Did you install it as well as add to config?
npm install artillery-plugin-metrics-by-endpoint
In terms of running sequentially, I'm not sure why you would want to, but assuming you do, you just need to define each POST as part of the same Scenario instead of 2 different scenarios. That way the second step will only execute after the first step has responded. I believe the plugin is per endpoint, not per scenario so will still give you the report you want.
I just started working with Rasa NLU and I have some problem understanding the usage of categorical slots with same values. I have 3 different types of risk, each a categorical slot with values: low, medium and high.
How can the bot differentiate between the three risks and understand which slot to be filled up, given the intent is same for each.
Or do I need to use different intents for each?
Right now what I see is (I removed unrelated logs):
How tired are you?
1: low (low)
2: medium (medium)
3: high (high)
medium
DEBUG:rasa_core.processor:Received user message 'medium' with intent '{'name': 'inform', 'confidence': 0.88372623999657118}' and entities '[{'start': 0, 'end': 6, 'value': 'medium', 'entity': 'fatigue', 'extractor': 'ner_crf'}]'
DEBUG:rasa_core.processor:Current slot values:
fatigue: medium
injury: None
stress: None
How stressed are you?
1: low (low)
2: medium (medium)
3: high (high)
low
DEBUG:rasa_core.processor:Received user message 'low' with intent '{'name': 'inform', 'confidence': 0.88762049990079372}' and entities '[{'start': 0, 'end': 3, 'value': 'low', 'entity': 'fatigue', 'extractor': 'ner_crf'}]'
DEBUG:rasa_core.processor:Current slot values:
fatigue: low
injury: None
stress: None
All the user replies have the intent inform.
An example story is:
* _greet[]
- utter_ask_fatigue
* _inform[fatigue=low]
- utter_ask_injury
* _inform[injury=medium]
- utter_ask_stress
* _inform[stress=low]
- utter_on_it
- action_reply
you can do it with one entity and four slots
the entity may be defined as type "info", with text values (i.e. low, medium, high).
The four slots: the first one is "info", which will auto filled by recognized entity "info" defined previously. The other three would be "fatigue", "stress" and "injury", which can be filled by bot actions such as action_fill_fatigue, action_fill_stress and action_fill_injury.
an example story will make it clear:
* _greet[]
- utter_ask_fatigue
* _inform[info=low]
- action_fill_fatigue
- utter_ask_injury
* _inform[info=medium]
- action_fill_injury
- utter_ask_stress
* _inform[info=low]
- action_fill_stress
- utter_on_it
- action_reply