예제 #1
0
 def __init__(self, filename, FLAGS=None):
     self.fn = filename
     self.log = logger.Logging()
     with open(filename, 'rb') as f:
         self.data = json.load(f)
         self.log.info('read in json data from %s' % filename)
     # create master dictionary key post.id value tags to each post
     self.d_insta = collections.defaultdict()
     #holder for set of columns found in any and all posts
     self.col_insta = set()
     #dictionary counting tags overall in the corpus
     self.tags = collections.defaultdict(int)
     #dictionary linking views to a post id
     self.views = collections.defaultdict(int)
     #dictionary of users
     self.users = collections.defaultdict()
     #dictionary of actual urls for quick view
     self.urls = collections.defaultdict()
     #dictionary of likes
     self.likes = collections.defaultdict(int)
     #dictionary of comments in edge, node format
     self.comments = collections.defaultdict()
     #dictionary of comments on a post image from other users - { pid : username : [ text, text, text ]}
     self.user_comments = collections.defaultdict()
     if FLAGS.create:
         self.create_data_dict()
         self.data_to_csv('tags', [
             k for k, v in sorted(
                 self.tags.items(), key=lambda val: val[1], reverse=True)
         ])
         self.data_to_csv('users', [
             v.get('username', v.get('id', ''))
             for k, v in self.users.items()
         ])
예제 #2
0
 def __init__(self, xtrain, ytrain, xtest, ytest, params=None):
     self.log = logger.Logging()
     self.xtrain = xtrain
     self.ytrain = ytrain
     self.xtest = xtest
     self.ytest = ytest
     if params is not None:
         self.params = params
         self.log.info('parameter values passed in: %s' % params.keys())
예제 #3
0
    def __init__(self, config_path=None, connect=None):
        self.config = None
        self.api_issues = None
        self.api_imaging = None
        self.api_data_entry = None
        self.api_import_laptops = None
        self.config_path = config_path
        self.logging = logger.Logging()

        self.configure()
        if connect:
            self.connect_servers()
예제 #4
0
    def __init__(self, debug=False):

        self._create_dirs()
        self.log = logger.Logging(debug=debug)

        self.gamerules = {}

        self.mconf = {}
        self.execute_after_stop = []

        self.players_online = {}

        self.firststart = 0

        self.is_online = False

        self.log.info('main', 'Getting configs...')

        if os.path.exists('./conf.json'):
            with open('./conf.json', 'r') as confl:
                self.mconf = json.load(confl)

        else:
            self.firststart = 1

        if 'version' not in list(self.mconf.keys()):
            self.mconf['version'] = VER
        elif 'version' in list(
                self.mconf.keys()) and self.mconf['version'] != VER:
            self.mconf = {'version': VER}

        if 'serverconfig' not in list(self.mconf.keys()):
            self.mconf['serverconfig'] = {
                'servername': 'BDS',
                'current_world': '',
                'backup_interval': 0,
                'checkupdate_interval': 86400,
                'reboot_interval': 604800,
                'session_keys': [],
                'startup_action': '',
                'password': None
            }
            self.log.warning('main', 'Password not setted')

        if 'worlds' not in list(self.mconf.keys()):
            if not os.path.exists('./worlds/'):
                os.mkdir('./worlds')
                self.mconf['worlds'] = {}
            else:
                self.mconf['worlds'] = {}
                self.iterworlds()
        self._sync()
예제 #5
0
    def __init__(self, interval=60):
        ##read settings from file
        self.settings_c = settings.Settings()
        ##enable logging
        self.logging = logger.Logging()
        ##loading database
        self.maindatabase = data.main_database()
        self.interval = interval
        self.page_handler = page_handler()
        self.setting_handler = setting_handler()
        self.item_handler = item_handler()
        self.state_handler = state_handler()
        self.message_handler = message_handler()
        self.task_scheduler = task_scheduler()

        thread = threading.Thread(target=self.run, args=())
        thread.daemon = True  # Daemonize thread
        thread.start()  # Start the execution
예제 #6
0
 def __init__(self, IP, FLAGS):
     self.log = logger.Logging()
     if not FLAGS.outfile:
         self.log.error('must supply an output file')
     else:
         if FLAGS.all:
             self.paragraphs = self.create_paragraphs(IP.comments.values())
             self.num_paragraphs = len(self.paragraphs)
             self.sentences = self.create_sentences(IP.comments.values())
             self.num_sentences = len(self.sentences)
             self.words, self.pos_words = self.create_words(IP.comments.values())
             self.num_words = len(self.words)
         elif FLAGS.sent:
             self.create_sentences(IP.comments.values())
             self.words, self.pos_words = self.create_words(IP.comments.values())
             self.num_words = len(self.words)
         elif FLAGS.para:
             self.create_paragraphs(IP.comments.values())
             self.words, self.pos_words = self.create_words(IP.comments.values())
             self.num_words = len(self.words)
예제 #7
0
 def __init__(self, FLAGS):
     self.FLAGS = FLAGS
     self.log = logger.Logging()
     if FLAGS.headless:
         self.log.info('running headless - feel free to use functionality')
         pass
     else:
         if FLAGS.train_file and FLAGS.train_col:
             self.train_data = pd.read_csv(FLAGS.train_file)
             if FLAGS.shuffle:
                 self.train_data = shuffle(self.train_data)
             self.train_yvals = self.train_data[FLAGS.train_col]
             self.train_yvals = self.train_yvals.as_matrix()
             self.train_xvals = self.train_data.ix[:,
                                                   self.train_data.columns
                                                   != FLAGS.train_col]
             self.train_xvals = self.train_xvals.as_matrix()
             if FLAGS.distort:
                 #print(self.train_xvals[0], np.floor(self.train_xvals[0] * .9))
                 percent = int(len(self.train_xvals) * .95)
                 print('distorting images: ', self.train_xvals[percent:])
                 self.train_xvals[percent:] = np.floor(
                     self.train_xvals[percent:] * .81)
                 self.train_xvals[:-percent] = np.floor(
                     self.train_xvals[:-percent:] * .91)
                 #half = int(len(self.train_xvals / 2))
                 #self.train_xvals[:two_percent] = self.dampen_data(self.train_xvals[:two_percent], 15)
                 #self.train_xvals[half:half+two_percent] = self.rotate_data(self.train_xvals[half:half+two_percent])
             self.log.info('read in train matrix %s' %
                           self.train_data.shape[0])
         if FLAGS.test_file and FLAGS.test_col:
             self.test_data = pd.read_csv(FLAGS.test_file)
             self.test_yvals = self.test_data[FLAGS.test_col]
             self.test_yvals = self.test_yvals.as_matrix()
             self.test_xvals = self.test_data.ix[:, self.test_data.
                                                 columns != FLAGS.test_col]
             self.test_xvals = self.test_xvals.as_matrix()
             self.log.info('read in test matrix %s' %
                           self.test_data.shape[0])
예제 #8
0
 def __init__(self, filename, FLAGS=None):
     self.fn = filename
     self.log = logger.Logging()
     with open(filename, 'rb') as f:
         self.data = json.load(f)
         self.log.info('read in json data from %s' % filename)
     # create master dictionary key post.id value tags to each post
     self.d_insta = collections.defaultdict()
     #holder for set of columns found in any and all posts
     self.col_insta = set()
     #dictionary counting tags overall in the corpus
     self.tags = collections.defaultdict(int)
     #dictionary linking views to a post id
     self.views = collections.defaultdict(int)
     #dictionary of users
     self.users = collections.defaultdict()
     #dictionary of actual urls for quick view
     self.urls = collections.defaultdict()
     #dictionary of likes
     self.likes = collections.defaultdict(int)
     #dictionary of comments in edge, node format
     self.comments = collections.defaultdict()
     if FLAGS.create:
         self.create_data_dict()
예제 #9
0
import logger

logging = logger.Logging(name='main', filename='logging')
logging.debug('一个debug信息')

varibale = 'hello logging '
logging.info('info1 %s' 'info2' 'info3', varibale)
예제 #10
0
    def __init__(self):
        self.control_file = 'config_imgs.txt'
        config = self.read_control_file(self.control_file)
        self.use_max = bool(int(config['use_max'][0]))
        self.fig_dim = int(
            config['fig_dim']
            [0])  #sets the figsize, figsize*dpi gives pixel dimensions
        self.plot_dpi = int(
            config['plot_dpi'][0]
        )  #sets resolution of figure, figsize*dpi gives pixel dimensions
        self.percent_label_days = map(int, config['outlook'][0].split(','))
        self.labels_only = bool(int(config['labels_only'][0]))
        self.filenames = config['symbols'][0].split(',')
        self.ndays = map(int, config['ndays'][0].split(','))
        self.normalized = bool(int(config['normalized'][0]))
        self.log = logger.Logging()
        self.data = self.load_ohlc_csv('store/amd_100d.csv')
        self.ohlc = self.reorder_data_columns()

        print "Sample driver code"
        print(''' 

    def driver(self):
        arr_full = self.convert_dataframe_to_np_array()
        arr_full = self.change_date(arr_full,0)
        #lines,patches = ic.create_image_from_np_array(arr)
        num_windows = self.get_num_windows()
        self.log.info('creating figure from full dataframe...')
        lines, patches = self.create_image_from_numpy_array(arr_full,num_windows)
        ### figure for windows of nday data
        self.log.info('creating first windowed figure...')
        candle_stick,fig_windows,ax_windows,img_arr = self.create_figure_instance(arr_full)
        img_arr = self.delete_alpha(img_arr)
        ### Check this
        shape, label = self.get_labels(arr_full[0:self.ndays],img_arr)
        labels = np.asarray([label])
        img_arr = self.flatten_image(img_arr)
        img_arr = self.append_shape(img_arr,shape)
        if self.write_dir == None:
            ### skip directory
            self.log.info('skipping directory...')
            num_windows = 1
        else:
            self.log.info('saving array...')
            write_file = self.save_array(img_arr,0)


        for i in range(1,num_windows):
            self.log.info("window {} ".format(i))
            arr = ic.get_current_window(arr_full,i)
            self.log.info('getting next plot data...')
            newlinedata, newlinecolor, newpatchdata = ic.get_new_plot_data(lines,patches,i)
            self.log.info('updating line data...')
            candle_stick = ic.update_current_data(candle_stick,newlinedata,newlinecolor,newpatchdata,i)
            self.log.info('redrawing image...')
            img_arr = ic.redraw_image(candle_stick,fig_windows,ax_windows,i,arr)

            img_arr = self.delete_alpha(img_arr)
            shape, label = self.get_labels(arr,img_arr)
            labels = np.append(labels,label)
            img_arr = self.flatten_image(img_arr)
            img_arr = self.append_shape(img_arr,shape)

            self.log.info("saving array...")
            write_file = self.save_array(img_arr,i)
            'write_file = self.write_dir + window(count)_label(self.percent_label_days)d'
            where self.write_dir is
            'self.write_dir = ./imgs_as_arrays/(symbol)/(n)/'
            and items wrapped in () are variables in code

            #self.recreate_image(write_file,imshow = True)

        if self.label_dir == None:
            label_dir set by write_dir: if write dir is full then label_dir will pass over saving
            pass
        else:
            self.log.info('saving yvals...')
            self.save_label(labels)
        ### Close plot at end
        plt.close()


            #self.recreate_image(write_file,imshow=True); method to recreate image from array, imshow=True displays image during runtime
            ''')
예제 #11
0
    ImportParser.add_argument('--spotinst_token',
                              dest='api_token',
                              required=True,
                              help='Spotinst API Token')
    ImportParser.add_argument('--spotinst_accountid',
                              dest='api_accountid',
                              required=True,
                              help='Spotinst Account ID linked to token')
    ImportParser.add_argument('-v',
                              '--verbose',
                              dest='VerboseMode',
                              action='count',
                              default=int(0),
                              help='enable verbose output (-vv for more)')
    options = ImportParser.parse_args()
    api_token = options.api_token
    api_accountid = options.api_accountid
    VerboseMode = options.VerboseMode

    logger.Logging().configure(VerboseMode)
    log = logger.logging.getLogger('Logger')
    #loggers = [logger.logging.getLogger(name) for name in logger.logging.root.manager.loggerDict]
    #print(loggers)

    client = SpotinstClient(auth_token=api_token, account_id=api_accountid)
    getaccounts = client.get_accounts()
    for account in getaccounts:
        print('Spotinst Account ID: {} AWS Account ID: {}  Account Name: {}'.
              format(account['account_id'], account['provider_external_id'],
                     account['name']))
예제 #12
0
 def __init__(self, items=None):
     self.log = logger.Logging()
     self.G = nx.Graph()