def cameras_checker(self):
cameras = [
{'name': 'Купол 12', 'ip': IP12, 'rebootIp': RODOS12, 'fails': 0},
{'name': 'Купол 13', 'ip': IP13, 'rebootIp': RODOS13, 'fails': 0},
]
while True:
for camera in cameras:
cmd = f"ping {camera['ip']} -n 1 -w 100"
response = subprocesscall(cmd, stdout=subprocess.DEVNUL)
if not response:
print(f'Camera {camera['name']} ok')
camera['fails'] = 0
else:
camera['fails'] += 1
print(f"Camera {camera['name']} died")
if camera['fails'] = 5:
self.cameras_reboot(camera['rebootIp'])
sleep(5)
$taxAuthorities = $this->db->entityManager
->getRepository(TaxAuthority::class)
->findBy(['active' => true]);
foreach ($taxAuthorities as $taxAuthority) {
// здесь работа с объектом через геттеры
// например, $taxAuthority->getTaxType()
}
$qb = $this->db->entityManager->createQueryBuilder();
$query = $qb
->select('ta.taName', 'ta.taId', 'ta.taAmount', 'tam.tamColumnValue', 'tp.tpId', 'tp.tpName')
->from(TaxAuthority::class, 'ta')
->innerJoin(TaxType::class, 'tt', Join::WITH, $qb->expr()->eq('tt.ttId', 'ta.taTtId'))
->innerJoin(TaxAuthMatch::class, 'tam', Join::WITH, $qb->expr()->eq('tam.tamTaId', 'ta.taId'))
->innerJoin(TaxTypeMatch::class, 'ttm', Join::WITH, $qb->expr()->eq('ttm.ttmTtId', 'tt.ttId'))
->innerJoin(TaxProfileDefs::class, 'tpd', Join::WITH, $qb->expr()->eq('tpd.tpdTtId', 'tt.ttId'))
->innerJoin(TaxProfile::class, 'tp', Join::WITH, $qb->expr()->eq('tp.tpId', 'tpd.tpdTpId'))
->where($qb->expr()->eq('ta.taActive', 'Y'))
->orderBy('tam.tamColumnValue');
// Посмотреть текст DQL
// echo $query->getDQL();
$result = $query->getQuery()->getResult();
def get_result(self):
if not self.data:
return None
if len(self.data) % 2 == 1:
return float(self.data[len(self.data) // 2])
return float(self.data[len(self.data) // 2 - 1] + self.data[len(self.data) // 2]) / 2
class MinValue:
def __init__(self):
self.min = None
def add(self, number):
if number < self.min
self.min = number
def get_result(self):
return self.min
@commands.Cog.listener()
async def on_message(self, message):
if message.author == self.bot.user:
return
if message.channel.id != 1233498806881095824:
return
user_id = message.author.id
current_time = time.time()
if not msg_delay(user_id, self, current_time):
await message.channel.send("Ожидайте перед следующим обновлением опыта.")
return
user_name = message.author.name
xp_amount = 100
if message.attachments:
xp_amount = 150
self.last_xp_update[user_id] = current_time
database.increase_xp(user_id, user_name, xp_amount)
guild_id = message.guild.id
guild = self.bot.get_guild(guild_id)
member = guild.get_member(user_id)
if member == None:
return
id_add_role, id_delete_role = await get_role_ids(user_id, user_name, db_levels, database)
await manage_roles(member, guild, id_add_role, id_delete_role)
let response;
$(document).ajaxSuccess(function(e, xhr, settings) {
response = xhr.responseJSON
});