Esempio n. 1
0
 def __has_changed_side(self, side):
     try:
         sql = "select * from entry"
         entry = \
             repository.read_sql(database=self.DATABASE, sql=sql)
         if entry.empty:
             message.warning("entry empty")
             return True
         latest_side = entry.at[0, "side"]
         if latest_side != side:
             message.warning("change side from", side, "to", latest_side)
             return True
         else:
             return False
     except Exception:
         message.error(traceback.format_exc())
Esempio n. 2
0
    def position_validation(self, order_side, order_size):
        while True:
            try:
                time.sleep(120)

                if self.__has_changed_side(side=order_side):
                    return

                position = self.__get_position()
                position_side = position["side"]
                position_size = position["size"]

                if position_side is None \
                        or order_side != position_side:
                    message.warning("invalidate position")
                    self.order(order_side)
                elif order_size * 0.5 >= position_size:
                    message.warning("not enough position size")
                    self.order(order_side)
                elif order_size * 1.5 <= position_size:
                    message.warning("close invalidate position size")
                    side = self.__reverse_side(side=order_side)
                    size = position_size - order_size
                    price = self.__get_order_price(side=side)

                    assert self.is_valid_side(side=side)
                    assert self.is_valid_size(size=size)
                    assert self.is_valid_price(price=price)

                    self.__send_order(side=side, size=size, price=price)
                else:
                    return
            except Exception:
                message.error(traceback.format_exc())
                time.sleep(3)
Esempio n. 3
0
    {
        'WORK_DIR': '/home/customizer',
        'LOCALES': 'C',
        'RESOLUTION': '800x600',
        'COMPRESSION': 'gzip',
        'VRAM': '256',
        'ISO': '',
        'DEB': '',
        'HOOK': '',
        'KERNEL': 'default',
        'PURGE_KERNEL': True,
    }
)

if not os.path.isfile('/etc/customizer.conf'):
    message.warning('Configuration file does not exist', '/etc/customizer.conf')

conf.read('/etc/customizer.conf')
message.info('Read Configuration file', '/etc/customizer.conf')
for section in ('preferences', 'saved'):
    if not conf.has_section(section):
        conf.add_section(section)

# Make sure these end up to be strings in both python2 and python3.
WORK_DIR = '{}'.format(conf.get('preferences', 'WORK_DIR'))
LOCALES = '{}'.format(conf.get('preferences', 'LOCALES'))
RESOLUTION = '{}'.format(conf.get('preferences', 'RESOLUTION'))
COMPRESSION = '{}'.format(conf.get('preferences', 'COMPRESSION'))
VRAM = '{}'.format(conf.get('preferences', 'VRAM'))

ISO = '{}'.format(conf.get('saved', 'ISO'))
Esempio n. 4
0
conf = ConfigParser.SafeConfigParser(
    {
        "WORK_DIR": "/home",
        "LOCALES": "C",
        "RESOLUTION": "800x600",
        "COMPRESSION": "xz",
        "VRAM": "256",
        "ISO": "",
        "DEB": "",
        "HOOK": "",
    }
)

if not os.path.isfile("/etc/customizer.conf"):
    message.warning("Configuration file does not exists", "/etc/customizer.conf")

conf.read("/etc/customizer.conf")
for section in ("preferences", "saved"):
    if not conf.has_section(section):
        conf.add_section(section)

WORK_DIR = conf.get("preferences", "WORK_DIR")
LOCALES = conf.get("preferences", "LOCALES")
RESOLUTION = conf.get("preferences", "RESOLUTION")
COMPRESSION = conf.get("preferences", "COMPRESSION")
VRAM = conf.get("preferences", "VRAM")

ISO = conf.get("saved", "ISO")
DEB = conf.get("saved", "DEB")
HOOK = conf.get("saved", "HOOK")
Esempio n. 5
0
File: config.py Progetto: fluxer/spm
        'STRIP_SHARED': 'False',
        'STRIP_STATIC': 'False',
        'STRIP_RPATH': 'False',
        'IGNORE_MISSING': 'True',
        'CONFLICTS': 'False',
        'BACKUP': 'False',
        'SCRIPTS': 'False',
        'TRIGGERS': 'False',
    }
)
for section in ('spm', 'prepare', 'compile', 'install', 'merge'):
    if not conf.has_section(section):
        conf.add_section(section)

if not os.path.isfile(MAIN_CONF):
    message.warning('Configuration file does not exist', MAIN_CONF)
else:
    conf.read(MAIN_CONF)

    CACHE_DIR = conf.get('spm', 'CACHE_DIR')
    BUILD_DIR = conf.get('spm', 'BUILD_DIR')
    ROOT_DIR = conf.get('spm', 'ROOT_DIR')
    LOCAL_DIR = ROOT_DIR + 'var/local/spm'
    IGNORE = conf.get('spm', 'IGNORE')
    MIRROR = conf.getboolean('prepare', 'MIRROR')
    TIMEOUT = conf.getint('prepare', 'TIMEOUT')
    EXTERNAL = conf.getboolean('prepare', 'EXTERNAL')
    CHOST = conf.get('compile', 'CHOST')
    CFLAGS = conf.get('compile', 'CFLAGS')
    CXXFLAGS = conf.get('compile', 'CXXFLAGS')
    CPPFLAGS = conf.get('compile', 'CPPFLAGS')