def __init__(self): self._globals = globals.Globals() if not os.path.exists(self._globals.confDir): try: os.makedirs(self._globals.confDir) except OSError, error: raise ConfigurationError(error)
def __init__(self, args, options): self._args = args self._options = options self._usage = "usage: Dandrop start|stop|restart|create|status|config|factoryreset|help" self._app = AppManager(self.pid_file(), debug=self._options.debugmode) self._config = self._app._config self._globs = globals.Globals() self.parseArgs()
def __init__(self, pidfile, debug=False): Daemon.__init__(self, pidfile=pidfile, verbose=0) self._systray = None # Get the globals self._globals = globals.Globals() # Create the logger self._logger = log.Logger(self._globals.logFile) # Load settings self._configOld = Config(self._globals.cfgFile, self._globals.DEFAULT_CONFIG) self._config = Configuration() self._globals.config = self._config self._config.debugEnabled = debug # Set the log level self._logger.set_level(self._config.logLevel)
import torchvision.datasets as dset import matplotlib.pyplot as plt from collections import Counter import cv2 import numpy as np import matplotlib.image as mpimg from tqdm import tqdm from scipy import linalg from sklearn.cluster import KMeans import os import globals from metric import dista1e, wasserstein, knn, mmd, i1eption_score, mode_score, fid g = globals.Globals() ## ResNet feature generator device_id = 0 def get_features(imgs, batch_size=100): resnet = models.resnet34(pretrained=True).cuda(device_id).eval() resnet_feature = nn.Sequential(resnet.conv1, resnet.bn1, resnet.relu, resnet.maxpool, resnet.layer1, resnet.layer2, resnet.layer3, resnet.layer4).cuda(device_id).eval() trans = transforms.Compose([ transforms.ToPILImage(), transforms.Scale(64), transforms.ToTensor(), transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),
data = json.load(hesaplar) for h in data["hesaplar"]: hesap_listesi.append(h) print("Hesaplar yüklendi. Hesaplara giriş için sms gönderilecek.") for hesap in hesap_listesi: client = fonksiyonlar.startAuth(hesap) client_list.append(client) with open("ayarlar.json") as ayar: d = json.load(ayar) eklenecekgrup = d["uyelerin_eklenecegi_grup"] cekilecekgrup = d["uyelerin_cekilecegi_grup"] uyelist,cek,ekle = fonksiyonlar.startHandler(eklenecekgrup,cekilecekgrup,client_list[0]) globals.Globals(uyelist) fonksiyonlar.disconnect(client_list) # globals.Globals.getInstance().getUye().Username hesap_sayisi = len(hesap_listesi) hesap_basi_uye = (globals.Globals.getInstance().getLen() // hesap_sayisi) i = 0 loop = asyncio.new_event_loop() for h in hesap_listesi: loop.create_task(fonksiyonlar.ThreadHandler(client_list[i],ekle,hesap_basi_uye,h,loop,eklenecekgrup)) print(i) #t = threading.Thread(target=fonksiyonlar.ThreadHandler,args=(client_list[i],ekle,hesap_basi_uye,h,loop,)) i +=1 #t.start() loop.run_forever()
def handle(self): client_info = "Client connected from %s\n\r" % self.client_address[0] #self.wfile.write(client_info) welcome_message = "Welcome to RoshanDrop (%s). Type \"help\" for a list with all available commands.\n\r" % str(date.today()) #self.wfile.write(welcome_message) #self.wfile.write_line_break() command = self.rfile.readline().strip().lower() while command != None: if command == 'quit': # Quits the connection self.wfile.write("Closing connection. Hope to see you again!\n\r") break elif command == 'stop': # Stops watching the repository self.wfile.write("Stop watching...") RoshanDrop.stop() elif command == 'start': # Starts watching the repository self.wfile.write("Start watching...") RoshanDrop.start() elif command == 'help': # Shows all available commands and a help message self.wfile.write(self.help_message) elif command == 'exit': # Exits the daemon sys.exit(2) elif command == 'update_interval': # Sets the update interval # 1. Stop syncing # 2. Update sync interval (config + fswatcher) # 3. Resume syncing # TODO: Move it to the set section print "Update interval changed" elif command == 'about': pass elif command == 'version': self.wfile.write(globals.Globals().version + "\n\r") elif command.startswith('get'): parts = command.split(' ') if len(parts) == 1: # Return a list with all available option self.wfile.write(self.available_options) elif len(parts) == 2: option = parts[1] if option == "syncinterval": value = self._config.get_option('syncInterval', 'general') self.wfile.write(str(value) + "\n\r") elif option == "syncfolder": value = self._config.get_option('syncFolder', 'general') self.wfile.write(str(value) + "\n\r") elif option == "remoteuser": value = self._config.get_option('remoteUser', 'repository') self.wfile.write(str(value) + "\n\r") elif option == "remotehost": value = self._config.get_option('remoteHost', 'repository') self.wfile.write(str(value) + "\n\r") elif option == "remoterep": value = self._config.get_option('remoteRepositoryPath', 'repository') self.wfile.write(str(value) + "\n\r") elif command.startswith('set'): # Sets an option pass else: self.wfile.write("Invalid command\n\r") command = self.rfile.readline().strip().lower()
def setup(self): SocketServer.StreamRequestHandler.setup(self) self._logger = log.Logger() self._logger.info("Client connected") self._config = globals.Globals().config
#!/usr/bin/env python # Copyright (C) 2019 Dan Makes from fswatcher import FSWatcher from api_server import ApiServer from config import Config from configuration import Configuration from systray import Systray from daemon import Daemon from web_server import WebServer import globals import log import os # Initialize some global variables globalVars = globals.Globals() globalVars.baseDir = os.path.dirname(os.path.realpath(__file__)) class AppManager(Daemon): def __init__(self, pidfile, debug=False): Daemon.__init__(self, pidfile=pidfile, verbose=0) self._systray = None # Get the globals self._globals = globals.Globals() # Create the logger self._logger = log.Logger(self._globals.logFile)