Beispiel #1
0
class OneApiException(OneException):
    pass


class OneInternalException(OneException):
    pass


#
# Constants, naming follows those in Open Nebula Ruby API
#

from aenum import IntEnum

DATASTORE_TYPES = IntEnum('DATASTORE_TYPES', 'IMAGE SYSTEM FILE', start=0)
DATASTORE_STATES = IntEnum('DATASTORE_STATES', 'READY DISABLED', start=0)

DISK_TYPES = IntEnum('DISK_TYPES', 'FILE CD_ROM BLOCK RBD', start=0)

HISTORY_ACTION = IntEnum(
    'HISTORY_ACTION',
    'none migrate live-migrate shutdown shutdown-hard undeploy undeploy-hard hold release stop suspend resume boot delete delete-recreate reboot reboot-hard resched unresched poweroff poweroff-hard disk-attach disk-detach nic-attach nic-detach disk-snapshot-create disk-snapshot-delete terminate terminate-hard disk-resize deploy chown chmod updateconf rename resize update snapshot-resize snapshot-delete snapshot-revert disk-saveas disk-snapshot-revert recover retry monitor',
    start=0)

HOST_STATES = IntEnum(
    'HOST_STATES',
    'INIT MONITORING_MONITORED MONITORED ERROR DISABLED MONITORING_ERROR MONITORING_INIT MONITORING_DISABLED OFFLINE',
    start=0)
HOST_STATUS = IntEnum('HOST_STATUS', 'ENABLED DISABLED OFFLINE', start=0)
Beispiel #2
0
'''A script and set of functions for converting video files to a standard format'''
from os.path import splitext, getsize, isfile
from os import rename, remove
import sys
from time import sleep
from multiprocessing import Process, Manager
from subprocess import check_call, SubprocessError
from aenum import IntEnum
from arrow import utcnow as now
import psutil
from mediainfo import MediaInfo, MediaInfoError
from utils import process_converter_args, human_readable_size, percentage
from utils import log_successful_conversion, log_failed_conversion

ConversionStatus = IntEnum('ConversionStatus',
                           'NONE RUNNING PAUSED STOPPED ERROR DONE')


class Conversion(object):
    def __init__(self, src_file_path, dst_file_path, log_file_path):
        self.src = src_file_path
        self.dst = dst_file_path
        self.log = log_file_path
        try:
            self.info = MediaInfo(self.src)
            self.audio_bitrate = self.info.abr()
            self.height = self.info.video_height()
            self.width = self.info.video_width()
        except MediaInfoError:
            self.agent_result = {
                'error', 'Unable to load media info for: {}'.format(self.src)
Beispiel #3
0
class mybitarray(bitarray):
    def __lshift__(self, count):
        return self[count:] + type(self)('0') * count

    def __rshift__(self, count):
        return type(self)('0') * count + self[:-count]

    def __repr__(self):
        return "{}('{}')".format(type(self).__name__, self.to01())


# global constants
MAXGAMEMOVES = 2048
BOARD_SQUARE_NUMBER = 120
PIECES = IntEnum("PIECES",
                 "EMPTY wP wN wB wR wQ wK bP bN bB bR bQ bK",
                 start=0)
FILES = IntEnum(
    "FILES",
    "FILE_A FILE_B FILE_C FILE_D FILE_E FILE_F FILE_G FILE_H FILE_NONE",
    start=0)
RANKS = IntEnum(
    "RANKS",
    "RANK_1 RANK_2 RANK_3 RANK_4 RANK_5 RANK_6 RANK_7 RANK_8 RANK_NONE",
    start=0)
COLORS = IntEnum("COLORS", "WHITE BLACK BOTH", start=0)
START_FEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"

# lookup tables for piecelists and hardcoded values
PieceBig = np.array([0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1])
PieceMaj = np.array([0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1])
Beispiel #4
0
"""
NoteValue: 'NoteValue' = IntEnum(
    'NoteValue',
    {
        # note, this order is NOT random
        # raw note names are preferred to enharmonic equivalents
        # flats are preferrable to sharps (jazz musician here)
        'C': 0,
        'D': 2,
        'E': 4,
        'F': 5,
        'G': 7,
        'A': 9,
        'B': 11,
        'Db': 1,
        'Gb': 6,
        'Ab': 8,
        'Bb': 10,
        'Eb': 3,
        'C#': 1,
        'D#': 3,
        'G#': 8,
        'A#': 10,
        'F#': 6,
        # these are just weird, so they exist only as aliases for B/C E/F respectively.
        'Fb': 4,
        'E#': 5,
        'B#': 0,
        'Cb': 11
    })
"""