File tree Expand file tree Collapse file tree 2 files changed +31
-12
lines changed
Expand file tree Collapse file tree 2 files changed +31
-12
lines changed Original file line number Diff line number Diff line change @@ -105,5 +105,6 @@ venv.bak/
105105# mypy
106106.mypy_cache /
107107
108+
108109.idea /
109- .DS_Store
110+ .DS_Store ?
Original file line number Diff line number Diff line change 2323"""
2424
2525import logging
26- import requests
2726
2827try :
2928 from logging import NullHandler
@@ -32,21 +31,14 @@ class NullHandler(logging.Handler):
3231 def emit (self , record ):
3332 pass
3433
35- #logging.basicConfig(filename='contentstack.log', format='%(asctime)s - %(message)s', level=logging.INFO)
36- #logging.getLogger("Config")
3734
35+ # logging.basicConfig(filename='contentstack.log', format='%(asctime)s - %(message)s', level=logging.INFO)
36+ # logging.getLogger("Config")
3837
39- class Util :
40-
41- def __init__ (self ):
42- logging .error ('logging called in utils' )
43- pass
44-
45- @staticmethod
4638 def log (message : str ):
4739 logging .debug (message )
4840
49- @ classmethod
41+
5042 def is_connected (cls ):
5143 import socket
5244 try :
@@ -59,3 +51,29 @@ def is_connected(cls):
5951 return False
6052
6153
54+ def header_agents () -> dict :
55+
56+ import contentstack
57+ import platform
58+
59+ """
60+ Contentstack-User-Agent header.
61+ """
62+ header = {'sdk' : {
63+ 'name' : contentstack .__package__ ,
64+ 'version' : contentstack .__version__
65+ }}
66+ os_name = platform .system ()
67+ if os_name == 'Darwin' :
68+ os_name = 'macOS'
69+ elif not os_name or os_name == 'Java' :
70+ os_name = None
71+ elif os_name and os_name not in ['macOS' , 'Windows' ]:
72+ os_name = 'Linux'
73+ header ['os' ] = {
74+ 'name' : os_name ,
75+ 'version' : platform .release ()
76+ }
77+
78+ local_headers = {'X-User-Agent' : header , "Content-Type" : 'application/json' }
79+ return local_headers
You can’t perform that action at this time.
0 commit comments