semvec/pypi-packages huggingface dataset:
Jiangziyi 0.0.3
For Angela Jiang
License: MIT

<!--
 * @Author: Vincent Young
 * @Date: 2022-07-24 03:55:55
 * @LastEditors: Vincent Young
 * @LastEditTime: 2022-09-14 05:20:34
 * @FilePath: /Jiangziyi/README.md
 * @Telegram: https://t.me/missuo
 * 
 * Copyright © 2022 by Vincent, All Rights Reserved. 
-->
# Jiangziyi
This is a dependency package for the people I love.
pyamsi 1.11
Access windows anitmalware interface using python
License: MIT
Keywords: amsi,python-amsi,pyamsi

# py-amsi

py-amsi is a library that scans strings or files for malware using the Windows
Antimalware Scan Interface (AMSI) API. AMSI is an interface native to Windows 
that allows applications to ask the antivirus installed on the system
to analyse a file/string. AMSI is not tied to Windows Defender. Antivirus
providers implement the AMSI interface to receive calls from applications.
This library takes advantage of the API to make antivirus scans in python.
Read more about the Windows AMSI API [here](https://learn.microsoft.com/en-us/windows/win32/amsi/antimalware-scan-interface-portal).

## Installation
- Via pip
  
  ```
  pip install pyamsi
  ```
- Clone repository

  ```bash
  git clone https://github.com/Tomiwa-Ot/py-amsi.git
  cd py-amsi/
  python setup.py install
  ```

## Usage
```python
from pyamsi import Amsi

# Scan a file
Amsi.scan_file(file_path, debug=True) # debug is optional and False by default

# Scan string
Amsi.scan_string(string, string_name, debug=False) # debug is optional and False by default

# Both functions return a dictionary of the format
# {
#     'Sample Size' : 68,         // The string/file size in bytes
#     'Risk Level' : 0,           // The risk level as suggested by the antivirus
#     'Message' : 'File is clean' // Response message
# }
```

<table>
    <tr>
        <th>Risk Level</th>
        <th>Meaning</th>
    </tr>
    <tr>
        <td>0</td>
        <td>AMSI_RESULT_CLEAN (File is clean)</td>
    </tr>
    <tr>
        <td>1</td>
        <td>AMSI_RESULT_NOT_DETECTED (No threat detected)</td>
    </tr>
    <tr>
        <td>16384</td>
        <td>AMSI_RESULT_BLOCKED_BY_ADMIN_START (Threat is blocked by the administrator)</td>
    </tr>
    <tr>
        <td>20479</td>
        <td>AMSI_RESULT_BLOCKED_BY_ADMIN_END (Threat is blocked by the administrator)</td>
    </tr>
    <tr>
        <td>32768</td>
        <td>AMSI_RESULT_DETECTED (File is considered malware)</td>
    </tr>
</table>
opentelemetry-hook-sampler 0.0.3
OpenTelemetry hook sampler
License: MIT

# opentelemetry-hook-sampler

Custom function based sampler for `opentelemetry-python`.

## How to install

```
$ pip install opentelemetry-hook-sampler
```

## How to use

```python
import opentelemetry.trace
from opentelemetry.sdk.resources import SERVICE_NAME
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry_hook_sampler import HookSampler


def sampler_hook():
    """
    Sample 1 in 10 traces.
    
    The example is static, but you can get info from any context available
    in your application. E.g. http request, celery task, thread locals, etc.
    """
    return 10


resource = Resource(attributes={SERVICE_NAME: "foo"})
sampler = HookSampler(sampler_hook)
provider = TracerProvider(resource=resource, sampler=sampler)
opentelemetry.trace.set_tracer_provider(provider)
```

### Honeycomb specific

[Honeycomb expects](https://docs.honeycomb.io/manage-data-volume/sampling/) a
`SampleRate` attribute to normalize data. It is not OpenTelemetry spec, but
it is supported through `opentelemetry_hook_sampler.HoneycombHookSampler`.


### Sampler examples

#### [django-threadlocals](https://pypi.org/project/django-threadlocals/)

Be careful, threadlocals module don't work with async Django.

```python
from threadlocals.threadlocals import get_current_request


def sampler_hook():
    request = get_current_request()
    # 10% /foo requests
    if request.path == '/foo':
        return 10
    return 1
```

#### [django-g](https://pypi.org/project/django-g/)

```python
from django_g import get_current_request


def sampler_hook():
    request = get_current_request()
    # 10% /foo requests
    if request.path == '/foo':
        return 10
    return 1
```

#### [celery](https://pypi.org/project/celery/)

```python
import celery


def sampler_hook():
    task_name = celery.current_app.current_worker_task.request.task
    # 10% foo.bar.baz tasks
    if task_name == 'foo.bar.baz':
        return 10
    return 1
```