function
stringlengths 11
56k
| repo_name
stringlengths 5
60
| features
sequence |
---|---|---|
def dc_offset(signal):
"""Correct DC offset"""
log.debug('DC offset before: %.1f', np.sum(signal) / len(signal))
signal = signal - signal.sum(dtype=np.int64) / len(signal)
log.debug('DC offset after: %.1f', np.sum(signal) / len(signal))
return signal | riggsd/zcant | [
3,
1,
3,
8,
1483577342
] |
def highpassfilter(signal, samplerate, cutoff_freq_hz, filter_order=6):
"""Full spectrum high-pass filter (butterworth)"""
cutoff_ratio = cutoff_freq_hz / (samplerate / 2.0)
b, a = scipy.signal.butter(filter_order, cutoff_ratio, btype='high')
return scipy.signal.filtfilt(b, a, signal) | riggsd/zcant | [
3,
1,
3,
8,
1483577342
] |
def noise_gate_zc(times_s, freqs_hz, amplitudes, threshold_factor):
"""Discard low-amplitude portions of the zero-cross signal.
threshold_factor: ratio of root-mean-square "noise floor" below which we drop
"""
signal_rms = rms(amplitudes)
threshold = threshold_factor * signal_rms
log.debug('RMS: %.1f threshold: %0.1f (%.1f x RMS)', signal_rms, threshold, threshold_factor)
# ignore everything below threshold amplitude
mask = amplitudes >= threshold
return times_s[mask], freqs_hz[mask], amplitudes[mask] | riggsd/zcant | [
3,
1,
3,
8,
1483577342
] |
def interpolate(signal, crossings):
"""
Calculate float crossing values by linear interpolation rather than relying exclusively
on factors of samplerate. We find the sample values before and after the
theoretical zero-crossing, then use linear interpolation to add an additional fractional
component to the zero-crossing index (so our `crossings` indexes become float rather
than int). This surprisingly makes a considerable difference in quantized frequencies,
especially at lower divratios. However, this implementation isn't perfect, and it appears
to add an oscillating uncertainty to time & frequency as we approach nyquist (or, perhaps,
the zero-cross nyquist, which is something like samplerate / 2 / divratio). | riggsd/zcant | [
3,
1,
3,
8,
1483577342
] |
def calculate_amplitudes(signal, crossings):
# FIXME: slow (can we remain entirely in numpy here?)
#return np.asarray([chunk.mean() if chunk.any() else 0 for chunk in np.split(np.abs(signal), crossings)[:-1]])
# amazingly it is faster to call np.add.reduce()/len() than to use the numpy mean() method.
return np.asarray([np.add.reduce(chunk)/len(chunk) if chunk.any() else 0 for chunk in np.split(np.abs(signal), crossings)[:-1]]) | riggsd/zcant | [
3,
1,
3,
8,
1483577342
] |
def zero_cross(signal, samplerate, divratio, amplitudes=True, interpolation=False):
"""Produce (times in seconds, frequencies in Hz, and amplitudes) from calculated zero crossings"""
log.debug('zero_cross(..., %d, %d, amplitudes=%s, interpolation=%s)', samplerate, divratio, amplitudes, interpolation)
divratio //= 2 # required so that our algorithm agrees with the Anabat ZCAIM algorithm | riggsd/zcant | [
3,
1,
3,
8,
1483577342
] |
def hpf_zc(times_s, freqs_hz, amplitudes, cutoff_freq_hz):
"""Brickwall high-pass filter for zero-cross signals (simply discards everything < cutoff)"""
hpf_mask = np.where(freqs_hz > cutoff_freq_hz)
junk_count = len(freqs_hz) - np.count_nonzero(hpf_mask)
log.debug('HPF throwing out %d dots of %d (%.1f%%)' % (junk_count, len(freqs_hz), junk_count/len(freqs_hz)*100))
return times_s[hpf_mask], freqs_hz[hpf_mask], amplitudes[hpf_mask] if amplitudes is not None else None | riggsd/zcant | [
3,
1,
3,
8,
1483577342
] |
def wav2zc(fname, divratio=8, hpfilter_khz=20, threshold_factor=1.0, interpolation=False, brickwall_hpf=True):
"""Convert a single .wav file to Anabat format.
Produces (times in seconds, frequencies in Hz, amplitudes, metadata). | riggsd/zcant | [
3,
1,
3,
8,
1483577342
] |
def __init__(self, host=None, port=None):
super().__init__(host, port)
self.heights = {}
self.blocks = {}
self.txs = {}
self.load_testdata() | behas/bitcoingraph | [
62,
19,
62,
5,
1422445817
] |
def load_testdata(self):
p = Path(TEST_DATA_PATH)
files = [x for x in p.iterdir()
if x.is_file() and x.name.endswith('json')]
for f in files:
if f.name.startswith("block"):
height = f.name[6:-5]
with f.open() as jf:
raw_block = json.load(jf)
block_hash = raw_block['hash']
self.heights[int(height)] = block_hash
self.blocks[block_hash] = raw_block
elif f.name.startswith("tx"):
tx_hash = f.name[3:-5]
with f.open() as jf:
raw_block = json.load(jf)
self.txs[tx_hash] = raw_block | behas/bitcoingraph | [
62,
19,
62,
5,
1422445817
] |
def getblock(self, block_hash):
if block_hash not in self.blocks:
raise BitcoindException("Unknown block", block_hash)
else:
return self.blocks[block_hash] | behas/bitcoingraph | [
62,
19,
62,
5,
1422445817
] |
def getblockhash(self, block_height):
if block_height not in self.heights:
raise BitcoindException("Unknown height", block_height)
else:
return self.heights[block_height] | behas/bitcoingraph | [
62,
19,
62,
5,
1422445817
] |
def getrawtransaction(self, tx_id, verbose=1):
if tx_id not in self.txs:
raise BitcoindException("Unknown transaction", tx_id)
else:
return self.txs[tx_id] | behas/bitcoingraph | [
62,
19,
62,
5,
1422445817
] |
def handle_program_options():
parser = argparse.ArgumentParser(description="Create a 2D or 3D PCoA plot. By default"
", this script opens a window with the plot "
"displayed if you want to change certain aspects of "
"the plot (such as rotate the view in 3D mode). If "
"the -o option is specified, the plot will be saved "
"directly to an image without the initial display "
"window.")
parser.add_argument("-i", "--coord_fp", required=True,
help="Input principal coordinates filepath (i.e. resulting file "
"from principal_coordinates.py) [REQUIRED].")
parser.add_argument("-m", "--map_fp", required=True,
help="Input metadata mapping filepath [REQUIRED].")
parser.add_argument("-g", "--group_by", required=True,
help="Any mapping categories, such as treatment type, that will "
"be used to group the data in the output iTol table. For example,"
" one category with three types will result in three data columns"
" in the final output. Two categories with three types each will "
"result in six data columns. Default is no categories and all the"
" data will be treated as a single group.")
parser.add_argument("-d", "--dimensions", default=2, type=int, choices=[2, 3],
help="Choose whether to plot 2D or 3D.")
parser.add_argument("-c", "--colors", default=None,
help="A column name in the mapping file containing hexadecimal "
"(#FF0000) color values that will be used to color the groups. "
"Each sample ID must have a color entry.")
parser.add_argument("-s", "--point_size", default=100, type=int,
help="Specify the size of the circles representing each of the "
"samples in the plot")
parser.add_argument("--pc_order", default=[1, 2], type=int, nargs=2,
help="Choose which Principle Coordinates are displayed and in "
"which order, for example: 1 2. This option is only used when a "
"2D plot is specified.")
parser.add_argument("--x_limits", type=float, nargs=2,
help="Specify limits for the x-axis instead of automatic setting "
"based on the data range. Should take the form: --x_limits -0.5 "
"0.5")
parser.add_argument("--y_limits", type=float, nargs=2,
help="Specify limits for the y-axis instead of automatic setting "
"based on the data range. Should take the form: --y_limits -0.5 "
"0.5")
parser.add_argument("--z_limits", type=float, nargs=2,
help="Specify limits for the z-axis instead of automatic setting "
"based on the data range. Should take the form: --z_limits -0.5 "
"0.5")
parser.add_argument("--z_angles", type=float, nargs=2, default=[-134.5, 23.],
help="Specify the azimuth and elevation angles for a 3D plot.")
parser.add_argument("-t", "--title", default="", help="Title of the plot.")
parser.add_argument("--figsize", default=[14, 8], type=int, nargs=2,
help="Specify the 'width height' in inches for PCoA plots. "
"Default figure size is 14x8 inches")
parser.add_argument("--font_size", default=12, type=int,
help="Sets the font size for text elements in the plot.")
parser.add_argument("--label_padding", default=15, type=int,
help="Sets the spacing in points between the each axis and its "
"label.")
parser.add_argument("--legend_loc", default="best", choices=['best','upper right','upper left',
'lower left', 'lower right', 'right', 'center left', 'center right',
'lower center', 'upper center', 'center', 'outside', 'none'],
help="Sets the location of the Legend. Default: best.")
parser.add_argument("--annotate_points", action="store_true",
help="If specified, each graphed point will be labeled with its "
"sample ID.")
parser.add_argument("--ggplot2_style", action="store_true",
help="Apply ggplot2 styling to the figure.")
parser.add_argument("-o", "--out_fp", default=None,
help="The path and file name to save the plot under. If specified"
", the figure will be saved directly instead of opening a window "
"in which the plot can be viewed before saving.")
return parser.parse_args() | smdabdoub/phylotoast | [
13,
4,
13,
4,
1399302765
] |
def __init__(self, client, config, serializer, deserializer) -> None:
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_long_running_output(pipeline_response):
if cls:
return cls(pipeline_response, None, {}) | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_long_running_output(pipeline_response):
deserialized = self._deserialize('ApplicationGateway', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def list(
self,
resource_group_name: str,
**kwargs: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list.metadata['url'] # type: ignore
path_format_arguments = {
'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'),
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def list_all(
self,
**kwargs: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_all.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_long_running_output(pipeline_response):
if cls:
return cls(pipeline_response, None, {}) | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_long_running_output(pipeline_response):
if cls:
return cls(pipeline_response, None, {}) | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_long_running_output(pipeline_response):
deserialized = self._deserialize('ApplicationGatewayBackendHealth', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_long_running_output(pipeline_response):
deserialized = self._deserialize('ApplicationGatewayBackendHealthOnDemand', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def list_available_ssl_predefined_policies(
self,
**kwargs: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_available_ssl_predefined_policies.metadata['url'] # type: ignore
path_format_arguments = {
'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'),
}
url = self._client.format_url(url, **path_format_arguments)
# Construct parameters
query_parameters = {} # type: Dict[str, Any]
query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')
request = self._client.get(url, query_parameters, header_parameters)
else:
url = next_link
query_parameters = {} # type: Dict[str, Any]
request = self._client.get(url, query_parameters, header_parameters)
return request | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def count():
return pygame_sdl2.joystick.get_count() | kfcpaladin/sze-the-game | [
3,
6,
3,
18,
1471431660
] |
def __init__(self, kind="gas", volumeSpec=0.0, Specification=None, Assets=None, *args, **kw_args):
"""Initialises a new 'Medium' instance.
@param kind: Kind of this medium. Values are: "gas", "liquid", "solid"
@param volumeSpec: The volume of the medium specified for this application. Note that the actual volume is a type of measurement associated witht the asset.
@param Specification:
@param Assets:
"""
#: Kind of this medium. Values are: "gas", "liquid", "solid"
self.kind = kind
#: The volume of the medium specified for this application. Note that the actual volume is a type of measurement associated witht the asset.
self.volumeSpec = volumeSpec
self._Specification = None
self.Specification = Specification
self._Assets = []
self.Assets = [] if Assets is None else Assets
super(Medium, self).__init__(*args, **kw_args) | rwl/PyCIM | [
68,
33,
68,
7,
1238978196
] |
def getSpecification(self): | rwl/PyCIM | [
68,
33,
68,
7,
1238978196
] |
def setSpecification(self, value):
if self._Specification is not None:
filtered = [x for x in self.Specification.Mediums if x != self]
self._Specification._Mediums = filtered
self._Specification = value
if self._Specification is not None:
if self not in self._Specification._Mediums:
self._Specification._Mediums.append(self) | rwl/PyCIM | [
68,
33,
68,
7,
1238978196
] |
def getAssets(self): | rwl/PyCIM | [
68,
33,
68,
7,
1238978196
] |
def setAssets(self, value):
for p in self._Assets:
filtered = [q for q in p.Mediums if q != self]
self._Assets._Mediums = filtered
for r in value:
if self not in r._Mediums:
r._Mediums.append(self)
self._Assets = value | rwl/PyCIM | [
68,
33,
68,
7,
1238978196
] |
def addAssets(self, *Assets):
for obj in Assets:
if self not in obj._Mediums:
obj._Mediums.append(self)
self._Assets.append(obj) | rwl/PyCIM | [
68,
33,
68,
7,
1238978196
] |
def __init__(self, learner_name):
s = "Wrong learner_name, " + \
"see model_param_space.py for all available learners."
assert learner_name in param_space_dict, s
self.learner_name = learner_name | ChenglongChen/Kaggle_HomeDepot | [
467,
209,
467,
1,
1461682287
] |
def AddLoginWhiteList(self, request):
"""本接口(AddLoginWhiteList)用于添加白名单规则
:param request: Request instance for AddLoginWhiteList.
:type request: :class:`tencentcloud.yunjing.v20180228.models.AddLoginWhiteListRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.AddLoginWhiteListResponse`
"""
try:
params = request._serialize()
body = self.call("AddLoginWhiteList", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.AddLoginWhiteListResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def CloseProVersion(self, request):
"""本接口 (CloseProVersion) 用于关闭专业版。
:param request: Request instance for CloseProVersion.
:type request: :class:`tencentcloud.yunjing.v20180228.models.CloseProVersionRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.CloseProVersionResponse`
"""
try:
params = request._serialize()
body = self.call("CloseProVersion", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.CloseProVersionResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def CreateOpenPortTask(self, request):
"""本接口 (CreateOpenPortTask) 用于创建实时获取端口任务。
:param request: Request instance for CreateOpenPortTask.
:type request: :class:`tencentcloud.yunjing.v20180228.models.CreateOpenPortTaskRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.CreateOpenPortTaskResponse`
"""
try:
params = request._serialize()
body = self.call("CreateOpenPortTask", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.CreateOpenPortTaskResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def CreateUsualLoginPlaces(self, request):
"""此接口(CreateUsualLoginPlaces)用于添加常用登录地。
:param request: Request instance for CreateUsualLoginPlaces.
:type request: :class:`tencentcloud.yunjing.v20180228.models.CreateUsualLoginPlacesRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.CreateUsualLoginPlacesResponse`
"""
try:
params = request._serialize()
body = self.call("CreateUsualLoginPlaces", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.CreateUsualLoginPlacesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DeleteBashEvents(self, request):
"""根据Ids删除高危命令事件
:param request: Request instance for DeleteBashEvents.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DeleteBashEventsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DeleteBashEventsResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteBashEvents", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteBashEventsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DeleteBruteAttacks(self, request):
"""本接口 (DeleteBruteAttacks) 用于删除暴力破解记录。
:param request: Request instance for DeleteBruteAttacks.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DeleteBruteAttacksRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DeleteBruteAttacksResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteBruteAttacks", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteBruteAttacksResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DeleteMachine(self, request):
"""本接口(DeleteMachine)用于卸载云镜客户端。
:param request: Request instance for DeleteMachine.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DeleteMachineRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DeleteMachineResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteMachine", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteMachineResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DeleteMaliciousRequests(self, request):
"""本接口 (DeleteMaliciousRequests) 用于删除恶意请求记录。
:param request: Request instance for DeleteMaliciousRequests.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DeleteMaliciousRequestsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DeleteMaliciousRequestsResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteMaliciousRequests", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteMaliciousRequestsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DeleteNonlocalLoginPlaces(self, request):
"""本接口 (DeleteNonlocalLoginPlaces) 用于删除异地登录记录。
:param request: Request instance for DeleteNonlocalLoginPlaces.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DeleteNonlocalLoginPlacesRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DeleteNonlocalLoginPlacesResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteNonlocalLoginPlaces", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteNonlocalLoginPlacesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DeletePrivilegeRules(self, request):
"""删除本地提权规则
:param request: Request instance for DeletePrivilegeRules.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DeletePrivilegeRulesRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DeletePrivilegeRulesResponse`
"""
try:
params = request._serialize()
body = self.call("DeletePrivilegeRules", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeletePrivilegeRulesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DeleteReverseShellRules(self, request):
"""删除反弹Shell规则
:param request: Request instance for DeleteReverseShellRules.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DeleteReverseShellRulesRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DeleteReverseShellRulesResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteReverseShellRules", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteReverseShellRulesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DeleteUsualLoginPlaces(self, request):
"""本接口(DeleteUsualLoginPlaces)用于删除常用登录地。
:param request: Request instance for DeleteUsualLoginPlaces.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DeleteUsualLoginPlacesRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DeleteUsualLoginPlacesResponse`
"""
try:
params = request._serialize()
body = self.call("DeleteUsualLoginPlaces", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DeleteUsualLoginPlacesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeAccounts(self, request):
"""本接口 (DescribeAccounts) 用于获取帐号列表数据。
:param request: Request instance for DescribeAccounts.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeAccountsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeAccountsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeAccounts", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeAccountsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeAlarmAttribute(self, request):
"""本接口 (DescribeAlarmAttribute) 用于获取告警设置。
:param request: Request instance for DescribeAlarmAttribute.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeAlarmAttributeRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeAlarmAttributeResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeAlarmAttribute", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeAlarmAttributeResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeAttackLogs(self, request):
"""按分页形式展示网络攻击日志列表
:param request: Request instance for DescribeAttackLogs.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeAttackLogsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeAttackLogsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeAttackLogs", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeAttackLogsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeBashRules(self, request):
"""获取高危命令规则列表
:param request: Request instance for DescribeBashRules.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeBashRulesRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeBashRulesResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeBashRules", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeBashRulesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeComponentInfo(self, request):
"""本接口 (DescribeComponentInfo) 用于获取组件信息数据。
:param request: Request instance for DescribeComponentInfo.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeComponentInfoRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeComponentInfoResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeComponentInfo", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeComponentInfoResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeComponents(self, request):
"""本接口 (DescribeComponents) 用于获取组件列表数据。
:param request: Request instance for DescribeComponents.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeComponentsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeComponentsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeComponents", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeComponentsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeImpactedHosts(self, request):
"""本接口 (DescribeImpactedHosts) 用于获取漏洞受影响机器列表。
:param request: Request instance for DescribeImpactedHosts.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeImpactedHostsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeImpactedHostsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeImpactedHosts", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeImpactedHostsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeMachineInfo(self, request):
"""本接口(DescribeMachineInfo)用于获取机器详细信息。
:param request: Request instance for DescribeMachineInfo.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeMachineInfoRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeMachineInfoResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeMachineInfo", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeMachineInfoResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeMaliciousRequests(self, request):
"""本接口 (DescribeMaliciousRequests) 用于获取恶意请求数据。
:param request: Request instance for DescribeMaliciousRequests.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeMaliciousRequestsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeMaliciousRequestsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeMaliciousRequests", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeMaliciousRequestsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeNonlocalLoginPlaces(self, request):
"""本接口(DescribeNonlocalLoginPlaces)用于获取异地登录事件。
:param request: Request instance for DescribeNonlocalLoginPlaces.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeNonlocalLoginPlacesRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeNonlocalLoginPlacesResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeNonlocalLoginPlaces", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeNonlocalLoginPlacesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeOpenPortTaskStatus(self, request):
"""本接口 (DescribeOpenPortTaskStatus) 用于获取实时拉取端口任务状态。
:param request: Request instance for DescribeOpenPortTaskStatus.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeOpenPortTaskStatusRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeOpenPortTaskStatusResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeOpenPortTaskStatus", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeOpenPortTaskStatusResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeOverviewStatistics(self, request):
"""本接口用于(DescribeOverviewStatistics)获取概览统计数据。
:param request: Request instance for DescribeOverviewStatistics.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeOverviewStatisticsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeOverviewStatisticsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeOverviewStatistics", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeOverviewStatisticsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribePrivilegeRules(self, request):
"""获取本地提权规则列表
:param request: Request instance for DescribePrivilegeRules.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribePrivilegeRulesRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribePrivilegeRulesResponse`
"""
try:
params = request._serialize()
body = self.call("DescribePrivilegeRules", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribePrivilegeRulesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeProcessStatistics(self, request):
"""本接口 (DescribeProcessStatistics) 用于获取进程统计列表数据。
:param request: Request instance for DescribeProcessStatistics.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeProcessStatisticsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeProcessStatisticsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeProcessStatistics", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeProcessStatisticsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeProcesses(self, request):
"""本接口 (DescribeProcesses) 用于获取进程列表数据。
:param request: Request instance for DescribeProcesses.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeProcessesRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeProcessesResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeProcesses", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeProcessesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeReverseShellRules(self, request):
"""获取反弹Shell规则列表
:param request: Request instance for DescribeReverseShellRules.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeReverseShellRulesRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeReverseShellRulesResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeReverseShellRules", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeReverseShellRulesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeSecurityTrends(self, request):
"""本接口 (DescribeSecurityTrends) 用于获取安全事件统计数据。
:param request: Request instance for DescribeSecurityTrends.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeSecurityTrendsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeSecurityTrendsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeSecurityTrends", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeSecurityTrendsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeTags(self, request):
"""获取所有主机标签
:param request: Request instance for DescribeTags.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeTagsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeTagsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeTags", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeTagsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeVulInfo(self, request):
"""本接口 (DescribeVulInfo) 用于获取漏洞详情。
:param request: Request instance for DescribeVulInfo.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeVulInfoRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeVulInfoResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeVulInfo", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeVulInfoResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeVuls(self, request):
"""本接口 (DescribeVuls) 用于获取漏洞列表数据。
:param request: Request instance for DescribeVuls.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeVulsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeVulsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeVuls", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeVulsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeWeeklyReportInfo(self, request):
"""本接口 (DescribeWeeklyReportInfo) 用于获取专业周报详情数据。
:param request: Request instance for DescribeWeeklyReportInfo.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeWeeklyReportInfoRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeWeeklyReportInfoResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeWeeklyReportInfo", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeWeeklyReportInfoResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeWeeklyReportNonlocalLoginPlaces(self, request):
"""本接口 (DescribeWeeklyReportNonlocalLoginPlaces) 用于获取专业周报异地登录数据。
:param request: Request instance for DescribeWeeklyReportNonlocalLoginPlaces.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeWeeklyReportNonlocalLoginPlacesRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeWeeklyReportNonlocalLoginPlacesResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeWeeklyReportNonlocalLoginPlaces", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeWeeklyReportNonlocalLoginPlacesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def DescribeWeeklyReports(self, request):
"""本接口 (DescribeWeeklyReports) 用于获取周报列表数据。
:param request: Request instance for DescribeWeeklyReports.
:type request: :class:`tencentcloud.yunjing.v20180228.models.DescribeWeeklyReportsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.DescribeWeeklyReportsResponse`
"""
try:
params = request._serialize()
body = self.call("DescribeWeeklyReports", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.DescribeWeeklyReportsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def EditPrivilegeRule(self, request):
"""新增或修改本地提权规则
:param request: Request instance for EditPrivilegeRule.
:type request: :class:`tencentcloud.yunjing.v20180228.models.EditPrivilegeRuleRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.EditPrivilegeRuleResponse`
"""
try:
params = request._serialize()
body = self.call("EditPrivilegeRule", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.EditPrivilegeRuleResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def EditTags(self, request):
"""新增或编辑标签
:param request: Request instance for EditTags.
:type request: :class:`tencentcloud.yunjing.v20180228.models.EditTagsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.EditTagsResponse`
"""
try:
params = request._serialize()
body = self.call("EditTags", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.EditTagsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def ExportBashEvents(self, request):
"""导出高危命令事件
:param request: Request instance for ExportBashEvents.
:type request: :class:`tencentcloud.yunjing.v20180228.models.ExportBashEventsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.ExportBashEventsResponse`
"""
try:
params = request._serialize()
body = self.call("ExportBashEvents", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ExportBashEventsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def ExportMaliciousRequests(self, request):
"""本接口 (ExportMaliciousRequests) 用于导出下载恶意请求文件。
:param request: Request instance for ExportMaliciousRequests.
:type request: :class:`tencentcloud.yunjing.v20180228.models.ExportMaliciousRequestsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.ExportMaliciousRequestsResponse`
"""
try:
params = request._serialize()
body = self.call("ExportMaliciousRequests", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ExportMaliciousRequestsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def ExportNonlocalLoginPlaces(self, request):
"""本接口 (ExportNonlocalLoginPlaces) 用于导出异地登录事件记录CSV文件。
:param request: Request instance for ExportNonlocalLoginPlaces.
:type request: :class:`tencentcloud.yunjing.v20180228.models.ExportNonlocalLoginPlacesRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.ExportNonlocalLoginPlacesResponse`
"""
try:
params = request._serialize()
body = self.call("ExportNonlocalLoginPlaces", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ExportNonlocalLoginPlacesResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def ExportReverseShellEvents(self, request):
"""导出反弹Shell事件
:param request: Request instance for ExportReverseShellEvents.
:type request: :class:`tencentcloud.yunjing.v20180228.models.ExportReverseShellEventsRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.ExportReverseShellEventsResponse`
"""
try:
params = request._serialize()
body = self.call("ExportReverseShellEvents", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ExportReverseShellEventsResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def InquiryPriceOpenProVersionPrepaid(self, request):
"""本接口 (InquiryPriceOpenProVersionPrepaid) 用于开通专业版询价(预付费)。
:param request: Request instance for InquiryPriceOpenProVersionPrepaid.
:type request: :class:`tencentcloud.yunjing.v20180228.models.InquiryPriceOpenProVersionPrepaidRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.InquiryPriceOpenProVersionPrepaidResponse`
"""
try:
params = request._serialize()
body = self.call("InquiryPriceOpenProVersionPrepaid", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.InquiryPriceOpenProVersionPrepaidResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def ModifyAlarmAttribute(self, request):
"""本接口(ModifyAlarmAttribute)用于修改告警设置。
:param request: Request instance for ModifyAlarmAttribute.
:type request: :class:`tencentcloud.yunjing.v20180228.models.ModifyAlarmAttributeRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.ModifyAlarmAttributeResponse`
"""
try:
params = request._serialize()
body = self.call("ModifyAlarmAttribute", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ModifyAlarmAttributeResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def ModifyLoginWhiteList(self, request):
"""编辑白名单规则
:param request: Request instance for ModifyLoginWhiteList.
:type request: :class:`tencentcloud.yunjing.v20180228.models.ModifyLoginWhiteListRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.ModifyLoginWhiteListResponse`
"""
try:
params = request._serialize()
body = self.call("ModifyLoginWhiteList", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.ModifyLoginWhiteListResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def OpenProVersion(self, request):
"""本接口 (OpenProVersion) 用于开通专业版。
:param request: Request instance for OpenProVersion.
:type request: :class:`tencentcloud.yunjing.v20180228.models.OpenProVersionRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.OpenProVersionResponse`
"""
try:
params = request._serialize()
body = self.call("OpenProVersion", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.OpenProVersionResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def RecoverMalwares(self, request):
"""本接口(RecoverMalwares)用于批量恢复已经被隔离的木马文件。
:param request: Request instance for RecoverMalwares.
:type request: :class:`tencentcloud.yunjing.v20180228.models.RecoverMalwaresRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.RecoverMalwaresResponse`
"""
try:
params = request._serialize()
body = self.call("RecoverMalwares", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.RecoverMalwaresResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def RescanImpactedHost(self, request):
"""本接口 (RescanImpactedHost) 用于漏洞重新检测。
:param request: Request instance for RescanImpactedHost.
:type request: :class:`tencentcloud.yunjing.v20180228.models.RescanImpactedHostRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.RescanImpactedHostResponse`
"""
try:
params = request._serialize()
body = self.call("RescanImpactedHost", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.RescanImpactedHostResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def SetBashEventsStatus(self, request):
"""设置高危命令事件状态
:param request: Request instance for SetBashEventsStatus.
:type request: :class:`tencentcloud.yunjing.v20180228.models.SetBashEventsStatusRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.SetBashEventsStatusResponse`
"""
try:
params = request._serialize()
body = self.call("SetBashEventsStatus", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.SetBashEventsStatusResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def TrustMaliciousRequest(self, request):
"""本接口 (TrustMaliciousRequest) 用于恶意请求添加信任。
:param request: Request instance for TrustMaliciousRequest.
:type request: :class:`tencentcloud.yunjing.v20180228.models.TrustMaliciousRequestRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.TrustMaliciousRequestResponse`
"""
try:
params = request._serialize()
body = self.call("TrustMaliciousRequest", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.TrustMaliciousRequestResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def UntrustMaliciousRequest(self, request):
"""本接口 (UntrustMaliciousRequest) 用于取消信任恶意请求。
:param request: Request instance for UntrustMaliciousRequest.
:type request: :class:`tencentcloud.yunjing.v20180228.models.UntrustMaliciousRequestRequest`
:rtype: :class:`tencentcloud.yunjing.v20180228.models.UntrustMaliciousRequestResponse`
"""
try:
params = request._serialize()
body = self.call("UntrustMaliciousRequest", params)
response = json.loads(body)
if "Error" not in response["Response"]:
model = models.UntrustMaliciousRequestResponse()
model._deserialize(response["Response"])
return model
else:
code = response["Response"]["Error"]["Code"]
message = response["Response"]["Error"]["Message"]
reqid = response["Response"]["RequestId"]
raise TencentCloudSDKException(code, message, reqid)
except Exception as e:
if isinstance(e, TencentCloudSDKException):
raise
else:
raise TencentCloudSDKException(e.message, e.message) | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def rank2severity(rank):
""":Return: the BlameThrower severity for a bug of the given `rank`."""
if 1 <= rank <= 4:
return 'high'
elif rank <= 12:
return 'med'
elif rank <= 20:
return 'low'
else:
assert False | jkleint/blamethrower | [
3,
3,
3,
2,
1351636768
] |
def __init__(
self, plotly_name="ticktext", parent_name="densitymapbox.colorbar", **kwargs | plotly/plotly.py | [
13052,
2308,
13052,
1319,
1385013188
] |
def __init__(self, *args, **kwargs):
super(TypedItem, self).__init__(*args, **kwargs)
self['type'] = self.type_name | comsaint/legco-watch | [
7,
3,
7,
6,
1425877642
] |
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(520, 174)
self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
self.verticalLayout.setContentsMargins(6, 6, 6, 6)
self.verticalLayout.setObjectName("verticalLayout")
self.groupBox = QtWidgets.QGroupBox(Dialog)
self.groupBox.setTitle("")
self.groupBox.setObjectName("groupBox")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.groupBox)
self.horizontalLayout.setObjectName("horizontalLayout")
self.uiLBL_text = QtWidgets.QLabel(self.groupBox)
self.uiLBL_text.setTextFormat(QtCore.Qt.RichText)
self.uiLBL_text.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
self.uiLBL_text.setWordWrap(True)
self.uiLBL_text.setObjectName("uiLBL_text")
self.horizontalLayout.addWidget(self.uiLBL_text)
self.verticalLayout.addWidget(self.groupBox)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem)
self.uiBTN_saveReplace = QtWidgets.QPushButton(Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.uiBTN_saveReplace.sizePolicy().hasHeightForWidth())
self.uiBTN_saveReplace.setSizePolicy(sizePolicy)
self.uiBTN_saveReplace.setObjectName("uiBTN_saveReplace")
self.horizontalLayout_2.addWidget(self.uiBTN_saveReplace)
self.uiBTN_replace = QtWidgets.QPushButton(Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.uiBTN_replace.sizePolicy().hasHeightForWidth())
self.uiBTN_replace.setSizePolicy(sizePolicy)
self.uiBTN_replace.setObjectName("uiBTN_replace")
self.horizontalLayout_2.addWidget(self.uiBTN_replace)
self.uiBTN_cancel = QtWidgets.QPushButton(Dialog)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.uiBTN_cancel.sizePolicy().hasHeightForWidth())
self.uiBTN_cancel.setSizePolicy(sizePolicy)
self.uiBTN_cancel.setObjectName("uiBTN_cancel")
self.horizontalLayout_2.addWidget(self.uiBTN_cancel)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem1)
self.horizontalLayout_2.setStretch(1, 1)
self.horizontalLayout_2.setStretch(2, 1)
self.horizontalLayout_2.setStretch(3, 1)
self.verticalLayout.addLayout(self.horizontalLayout_2)
self.verticalLayout.setStretch(0, 1)
self.retranslateUi(Dialog)
QtCore.QObject.connect(self.uiBTN_saveReplace, QtCore.SIGNAL("clicked()"), Dialog.onSaveReplaceClicked)
QtCore.QObject.connect(self.uiBTN_replace, QtCore.SIGNAL("clicked()"), Dialog.onReplaceClicked)
QtCore.QObject.connect(self.uiBTN_cancel, QtCore.SIGNAL("clicked()"), Dialog.onCancelClicked)
QtCore.QObject.connect(Dialog, QtCore.SIGNAL("finished(int)"), Dialog.onDialogFinished)
QtCore.QMetaObject.connectSlotsByName(Dialog) | theetcher/fxpt | [
19,
7,
19,
2,
1405973188
] |
def cluster():
with moto.mock_ecs(), moto.mock_ec2():
boto3.setup_default_session(region_name="eu-west-1")
ec2 = boto3.resource("ec2", region_name="eu-west-1")
ecs = boto3.client("ecs", region_name="eu-west-1")
known_amis = list(ec2_backend.describe_images())
test_instance = ec2.create_instances(
ImageId=known_amis[0].id, MinCount=1, MaxCount=1
)[0]
instance_id_document = json.dumps(
ec2_utils.generate_instance_identity_document(test_instance)
)
cluster = ecs.create_cluster(clusterName="default")
ecs.register_container_instance(
cluster="default", instanceIdentityDocument=instance_id_document
)
yield cluster | LabD/ecs-deplojo | [
19,
5,
19,
5,
1446133044
] |
def connection(cluster):
return Connection() | LabD/ecs-deplojo | [
19,
5,
19,
5,
1446133044
] |
def definition():
path = os.path.join(BASE_DIR, "files/default_taskdef.json")
with open(path, "r") as json_file:
return TaskDefinition(json.load(json_file)) | LabD/ecs-deplojo | [
19,
5,
19,
5,
1446133044
] |
def default_config():
path = os.path.join(BASE_DIR, "files/default_config.yml")
with open(path, "r") as fh:
yield fh | LabD/ecs-deplojo | [
19,
5,
19,
5,
1446133044
] |
def __init__(self, rx_cobid, tx_cobid, node):
"""
:param int rx_cobid:
COB-ID that the server receives on (usually 0x600 + node ID)
:param int tx_cobid:
COB-ID that the server responds with (usually 0x580 + node ID)
:param canopen.LocalNode od:
Node object owning the server
"""
SdoBase.__init__(self, rx_cobid, tx_cobid, node.object_dictionary)
self._node = node
self._buffer = None
self._toggle = 0
self._index = None
self._subindex = None
self.last_received_error = 0x00000000 | christiansandberg/canopen | [
362,
159,
362,
67,
1474393338
] |
def init_upload(self, request):
_, index, subindex = SDO_STRUCT.unpack_from(request)
self._index = index
self._subindex = subindex
res_command = RESPONSE_UPLOAD | SIZE_SPECIFIED
response = bytearray(8)
data = self._node.get_data(index, subindex, check_readable=True)
size = len(data)
if size <= 4:
logger.info("Expedited upload for 0x%X:%d", index, subindex)
res_command |= EXPEDITED
res_command |= (4 - size) << 2
response[4:4 + size] = data
else:
logger.info("Initiating segmented upload for 0x%X:%d", index, subindex)
struct.pack_into("<L", response, 4, size)
self._buffer = bytearray(data)
self._toggle = 0
SDO_STRUCT.pack_into(response, 0, res_command, index, subindex)
self.send_response(response) | christiansandberg/canopen | [
362,
159,
362,
67,
1474393338
] |
def block_upload(self, data):
# We currently don't support BLOCK UPLOAD
# according to CIA301 the server is allowed
# to switch to regular upload
logger.info("Received block upload, switch to regular SDO upload")
self.init_upload(data) | christiansandberg/canopen | [
362,
159,
362,
67,
1474393338
] |
def block_download(self, data):
# We currently don't support BLOCK DOWNLOAD
logger.error("Block download is not supported")
self.abort(0x05040001) | christiansandberg/canopen | [
362,
159,
362,
67,
1474393338
] |
def segmented_download(self, command, request):
if command & TOGGLE_BIT != self._toggle:
# Toggle bit mismatch
raise SdoAbortedError(0x05030000)
last_byte = 8 - ((command >> 1) & 0x7)
self._buffer.extend(request[1:last_byte])
if command & NO_MORE_DATA:
self._node.set_data(self._index,
self._subindex,
self._buffer,
check_writable=True)
res_command = RESPONSE_SEGMENT_DOWNLOAD
# Add toggle bit
res_command |= self._toggle
# Toggle bit for next message
self._toggle ^= TOGGLE_BIT
response = bytearray(8)
response[0] = res_command
self.send_response(response) | christiansandberg/canopen | [
362,
159,
362,
67,
1474393338
] |
def abort(self, abort_code=0x08000000):
"""Abort current transfer."""
data = struct.pack("<BHBL", RESPONSE_ABORTED,
self._index, self._subindex, abort_code)
self.send_response(data)
# logger.error("Transfer aborted with code 0x{:08X}".format(abort_code)) | christiansandberg/canopen | [
362,
159,
362,
67,
1474393338
] |
def download(
self,
index: int,
subindex: int,
data: bytes,
force_segment: bool = False, | christiansandberg/canopen | [
362,
159,
362,
67,
1474393338
] |
Subsets and Splits