Skip to content

Commit 0d53bcd

Browse files
added asset testcases
1 parent 91f6132 commit 0d53bcd

File tree

2 files changed

+31
-12
lines changed

2 files changed

+31
-12
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,6 @@ venv.bak/
105105
# mypy
106106
.mypy_cache/
107107

108+
108109
.idea/
109-
.DS_Store
110+
.DS_Store?

contentstack/utils.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"""
2424

2525
import logging
26-
import requests
2726

2827
try:
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

0 commit comments

Comments
 (0)