Friday, December 17, 2021

Python strptime Polish month discrepency between Linux and Windows

 very similar to the russian issue 

We have discrepancy in Polish between Linux and Windows

Run this command in both Linux and WIndows version 


import locale

import datetime

locale.setlocale(locale.LC_ALL, "pl_PL")

datetime.datetime.strptime('2021-grudnia-17','%Y-%B-%d')  #works only in Linux

datetime.datetime.strptime('2021-Grudzień-17','%Y-%B-%d') #works only in Winods 

Tuesday, October 26, 2021

Python not all space are the same

 Lets look at the below 2 strings

'7 октября 2021'

'7 октября 2021'


They look exactly same but are not. Lets try this in Python 

str = '7 октября 2021'

str_1 = '7 октября 2021'

print(str == str_1) -->  you will get false here


so what is the difference, the space is different lets try this 

str = '7 октября 2021'
for s in str:
print("char is {0} and order is {1}".format(s,ord(s)))
str_1 = '7 октября 2021'

for s in str_1:
print("char is {0} and order is {1}".format(s,ord(s)))


the space in str is 

char is   and order is 160

while the space in str_1 is

char is   and order is 32


So if you try str.replace(' ',"/") it does not work. You need to try differently like this

str.replace(chr(160),'/')

Friday, October 15, 2021

Python strptime Russian month discrepency between Linux and Windows

There is more than a way to write the month in any given language for example in Russian the month September can be written in more than one way

But on Python's implementation of strptime there is a difference in how the windows  or Linux OS perceives the month. 

Just run this Python code in Windows and Linux and see the difference for yourself

import locale

import datetime

locale.setlocale(locale.LC_ALL, "ru_RU")

datetime.datetime.strptime('2021-сентября-18', '%Y-%B-%d')

datetime.datetime.strptime('2021-сентябрь-18', '%Y-%B-%d')


In Windows "сентябрь" works whereas in Linux "сентября" works. This is same for all the months since most of them end in either "рь"  or "ря"

Tuesday, August 17, 2021

Showing the ECS Running Task in Grafana

 Grafana has cloudwatch datasource but the default metrics are cpu and memory and there is no direct way to track the # of running task. But there is a way possible. 

Please follow the instruction for  seeing the running tasks in Cloudwatch and implement the same in Grafana

https://docs.aws.amazon.com/AmazonECS/latest/userguide/cloudwatch-metrics.html#cw_running_task_count