Exemplo n.º 1
0
def ftpmount (url, action):
	mountpoint = cfg.config('mountpoint')
	if action == 'mount':
		if os.path.isdir(mountpoint):
			command = ('beesu  "curlftpfs   -o allow_other  %s    %s"')  %  (url, mountpoint)
		else:
			command = ('beesu  "mkdir   -p %s &&  curlftpfs  -o allow_other  %s   %s"') % (mountpoint, url, mountpoint)
		try:		
			ret = subprocess.call(command, shell=True)
		except:
			ret = 2
		if ret == 0:
			dialog_text = (url + '<br>mount - OK')
			code = 0
		else:
			dialog_text = (url + '<br>mount - FAIL!!!')
			code = 1
	else:
		command = ('beesu  "umount  %s && rm -rf  %s"') % (mountpoint, mountpoint)
		try:
			ret = subprocess.call(command, shell=True)
		except:
			ret = 2
		if ret == 0:
			dialog_text = (url + '<br>unmount - OK')
			code = 0
		else:
			dialog_text = (url + '<br>unmount - FAIL!!!')
			code = 1
	
	return  [ dialog_text, code ]
Exemplo n.º 2
0
def ftpmount(url, action):
    mountpoint = cfg.config('mountpoint')
    if action == 'mount':
        if os.path.isdir(mountpoint):
            command = ('beesu  "curlftpfs   -o allow_other  %s    %s"') % (
                url, mountpoint)
        else:
            command = (
                'beesu  "mkdir   -p %s &&  curlftpfs  -o allow_other  %s   %s"'
            ) % (mountpoint, url, mountpoint)
        try:
            ret = subprocess.call(command, shell=True)
        except:
            ret = 2
        if ret == 0:
            dialog_text = (url + '<br>mount - OK')
            code = 0
        else:
            dialog_text = (url + '<br>mount - FAIL!!!')
            code = 1
    else:
        command = ('beesu  "umount  %s && rm -rf  %s"') % (mountpoint,
                                                           mountpoint)
        try:
            ret = subprocess.call(command, shell=True)
        except:
            ret = 2
        if ret == 0:
            dialog_text = (url + '<br>unmount - OK')
            code = 0
        else:
            dialog_text = (url + '<br>unmount - FAIL!!!')
            code = 1

    return [dialog_text, code]
Exemplo n.º 3
0
 def init_ftp(self, path):
     pass
     conf = config().get_cfg(path, 'ftp.conf')
     try:
         self.ftp = FTP(conf['host'], conf['port'],conf['user'], conf['password'], conf['path'], conf['local_path'], conf['protocol'])
     except Exception, e:
         raise e
Exemplo n.º 4
0
def getModGrey(green_list, dirPath):
	dirlist = os.listdir(dirPath)
	grey_list = []
	dirLs = []
	for file in dirlist:
		for modtype in cfg.config('modtype'):
			dirLs += re.findall('^.*.'+ modtype + '$', file)
	for a in (set(dirLs) - set(green_list)):  
		grey_list.append(a)
		grey_list.sort()
	return grey_list 
Exemplo n.º 5
0
def getModGrey(green_list, dirPath):
    dirlist = os.listdir(dirPath)
    grey_list = []
    dirLs = []
    for file in dirlist:
        for modtype in cfg.config('modtype'):
            dirLs += re.findall('^.*.' + modtype + '$', file)
    for a in (set(dirLs) - set(green_list)):
        grey_list.append(a)
        grey_list.sort()
    return grey_list
Exemplo n.º 6
0
def getModGrey(green_arr, dirPath):
    dirlist = os.listdir(dirPath)
    grey_list = []
    green_list = []
    dirLs = []
    for file in dirlist:
        for modtype in cfg.config('modtype'):
            dirLs += re.findall('^.*.' + modtype + '$', file)
            list(dirLs)
    for val in green_arr.values():
        green_list.append(val)
    grey_list = list(set(dirLs) - set(green_list))
    return grey_list
Exemplo n.º 7
0
def getModGrey(green_arr, dirPath):
	dirlist = os.listdir(dirPath)
	grey_list = []
	green_list = []
	dirLs = []
	for file in dirlist:
		for modtype in cfg.config('modtype'):
			dirLs += re.findall('^.*.'+ modtype + '$', file)
			list(dirLs)
	for val in green_arr.values():
		green_list.append(val)
	grey_list = list( set(dirLs) - set(green_list) )  
	return grey_list 
Exemplo n.º 8
0
def testSubdirs(dir, modArr):
    xzmList = []
    exitcode = 'none'
    for a in dir:
        for modtype in cfg.config('modtype'):
            names = glob.glob(a + '/*.' + modtype)
            for name in names:
                xzmList.append(name)

    if not len(xzmList) == 0:
        exitcode = 'grey'
    a = []
    for key, value in modArr.items():
        a.append(value + '/' + key)
        for mod in xzmList:
            for file in a:
                if mod == file:
                    exitcode = 'green'
                    break
        if exitcode == 'green':
            break
    return exitcode
Exemplo n.º 9
0
def testSubdirs(dir, modArr):
	xzmList = []
	exitcode = 'none'
	for a in dir:
		for modtype in cfg.config('modtype'):
			names = glob.glob(a + '/*.' + modtype)
			for name in names:
				xzmList.append(name)
			
	if not len(xzmList) == 0:
			exitcode = 'grey'
	a = []
	for key, value in modArr.items():
		a.append(value + '/' + key)
		for mod in xzmList:
			for file in a:
				if mod  == file:
					exitcode = 'green'
					break
		if exitcode == 'green':
			break
	return exitcode
Exemplo n.º 10
0
 def __init__(self, archivo, encryption=True):
     import cfg
     self.cfgm = cfg.config(archivo, encryption)
     return None
Exemplo n.º 11
0
#!/usr/bin/python
# -*- coding:utf-8 -*-
import sys, os, re, cgi, lib_mod_map, cfg, gettext

gettext.install('mod_mnger', './locale', unicode=True)

allEnabled = []
dialog_text = 'none'
n = 1 

# Определяем пути, см cfg.py
paths = cfg.config('all')
base = paths['base_path']
modules = paths['mod_path']
optional = paths['opt_path']
data_modules = paths['data_mod_path']
data_optional = paths['data_opt_path']
copy2ram = paths['copy2ram']

# анализ cgi запроса
form = cgi.FieldStorage()
modname = form.getvalue('modname') or 'none' 
action = form.getvalue('action') or 'none'

if modname == 'none':
	pass
else:
	if action == 'activate':
		dialog_text = lib_mod_map.activate( modname )
	elif action == 'deactivate':
		dialog_text = lib_mod_map.deactivate( modname )
Exemplo n.º 12
0
)  #why do we have coefficent 2 here? *Make sure we have dataset big enough

prob_dist = class_dist / class_dist.sum()
choices = np.random.choice(class_dist.index, p=prob_dist)

fig, ax = plt.subplots()
ax.set_title('Class Distribution', y=1.08)
ax.pie(class_dist,
       labels=class_dist.index,
       autopct='%1.1f%%',
       shadow=False,
       startangle=90)
ax.axis('equal')
plt.show()

config = config(mode='conv')

if config.mode == 'conv':
    X, y = build_rand_feat()
    y_flat = np.argmax(y, axis=1)
    input_shape = (X.shape[1], X.shape[2], 1)
    model = get_conv_model()  # to be added later

elif config.mode == 'resnet':
    X, y = build_rand_feat()
    y_flat = np.argmax(y, axis=1)
    input_shape = (X.shape[1], X.shape[2], 1)
    model = get_resnet_model()  # to be added later

class_weight = compute_class_weight('balanced', np.unique(y_flat), y_flat)
Exemplo n.º 13
0
parser = argparse.ArgumentParser()
parser.add_argument('--experiment', type=str, default='', help="Experiment: mnist or chairs or msceleb")
parser.add_argument('--dc', type=int, default=10, help="content dimensions")
parser.add_argument('--ds', type=int, default=10, help="style dimensions")
parser.add_argument('--ac', type=str, default="NONE", help="accumulation")
parser.add_argument('--gs', type=int, default=2, help="group size")
parser.add_argument('--mi', type=str, default="NONE", help="mutual information minimization type")
parser.add_argument('--b1', type=float, default=1.0, help="beta1")
parser.add_argument('--b2', type=float, default=1.0, help="beta2")
parser.add_argument('--outdir', type=str, default="out", help="output directory")
parser.add_argument('--resume', type=bool, default=False, help="resume training")

FLAGS = parser.parse_args()

cfg.config(FLAGS.experiment)

cfg.cfg.ZC_dim = FLAGS.dc
cfg.cfg.ZS_dim = FLAGS.ds
cfg.cfg.Z_dim = cfg.cfg.ZC_dim+cfg.cfg.ZS_dim

cfg.cfg.accumulation = cfg.AccumulationType[FLAGS.ac]
cfg.cfg.groupSize = FLAGS.gs
cfg.cfg.mutualInformation = cfg.MutualInformationType[FLAGS.mi]
cfg.cfg.beta1 = FLAGS.b1
cfg.cfg.beta2 = FLAGS.b2

cfg.cfg.outdir = FLAGS.outdir
cfg.cfg.outdirImages = cfg.cfg.outdir + '/images'
cfg.cfg.save_path = cfg.cfg.outdir + '/saves'
Exemplo n.º 14
0
import cgitb
cgitb.enable()

# for gettext
mount = _('Mount').encode('UTF-8')
umount = _('Unmount ftp').encode('UTF-8')
Repository = _('Repository:').encode('UTF-8')
Search = _('Search:').encode('UTF-8')
title = _('Repository filelist, click link to choose action').encode('UTF-8')
allready_mounted = _(
    'Repository allready mounted, <br> mountpoint is:').encode('UTF-8')
mount_ftp = _('Mouting ftp server:').encode('UTF-8')
update = _('Server last update:').encode('UTF-8')

repository = cfg.config('repository')
mountpoint = cfg.config('mountpoint') + '/'
modType = cfg.config('modtype')
dialog_text = [
    'none',
]
n = 1

# анализ cgi запроса
form = cgi.FieldStorage()
url = form.getvalue('url') or 'none'
action = form.getvalue('action') or 'none'


def getList(pathDir):
    dirlist = os.listdir(pathDir)
Exemplo n.º 15
0
from keras.models import Sequential
from keras.layers import Conv2D, Flatten, Dropout, MaxPooling2D, Dense, BatchNormalization
from keras.callbacks import ModelCheckpoint
from keras.utils import to_categorical

#for efficient GPU use
import tensorflow as tf
from keras.backend import tensorflow_backend

conf = tf.ConfigProto(gpu_options=tf.GPUOptions(allow_growth=True))
session = tf.Session(config=conf)
tensorflow_backend.set_session(session)

from sklearn.utils.class_weight import compute_class_weight

config = config()
Path = "C:\\Users\\sarth\\Desktop\\datasets\\UrbanSound8K\\metadata"
f = os.path.join(Path, 'UrbanSound8K.csv')
df = pd.read_csv(f)
df.rename(columns={'class': 'label'}, inplace=True)
classes = list(np.unique(df.label))

x_tr, x_te, y_tr, y_te = [], [], [], []


def features():
    x, xt = [], []
    for i in tqdm(range(len(df))):
        #for i in range(3):
        fold = df.iloc[i]['fold']
        file_name = df.iloc[i]['slice_file_name']
Exemplo n.º 16
0
gettext.install('mod_mnger', './locale', unicode=True)

import cgitb
cgitb.enable()

# for gettext
mount = _('Mount').encode('UTF-8') 
umount = _('Unmount ftp').encode('UTF-8') 
Repository = _('Repository:').encode('UTF-8')
Search = _('Search:').encode('UTF-8')
title = _('Repository filelist, click link to choose action').encode('UTF-8')
allready_mounted = _('Repository allready mounted, <br> mountpoint is:').encode('UTF-8')
mount_ftp  = _('Mouting ftp server:').encode('UTF-8')
update = _('Server last update:').encode('UTF-8')

repository = cfg.config('repository')
mountpoint = cfg.config('mountpoint') + '/'
modType = cfg.config('modtype')
dialog_text = ['none',]
n = 1

# анализ cgi запроса
form = cgi.FieldStorage()
url = form.getvalue('url') or 'none' 
action = form.getvalue('action') or 'none'


def getList(pathDir):
	dirlist = os.listdir(pathDir)
	dirLs = []
	for file in dirlist:
Exemplo n.º 17
0
# sample size may be different
samples = 2 * int(data_frame["length"].sum() / 0.1)
probability_dist = class_dist / class_dist.sum()
choices = np.random.choice(class_dist.index, p=probability_dist)

figure, axis = plt.subplots()
axis.set_title('Class Distribution', y=1.08)
axis.pie(class_dist,
         labels=class_dist.index,
         autopct='%1.1f%%',
         shadow=False,
         startangle=90)
axis.axis('equal')
plt.show()

config = config("cnn")

if config.mode == "cnn":
    X, y = build_random_features()
    y_flat = np.argmax(y, axis=1)
    input_shape = (X.shape[1], X.shape[2], 1)
    model = get_cnn_model()

elif config.mode == "rnn":
    X, y = build_random_features()
    y_flat = np.argmax(y, axis=1)
    input_shape = (X.shape[1], X.shape[2])
    model = get_rnn_model()

class_weight = compute_class_weight("balanced", np.unique(y_flat), y_flat)
checkpoint = ModelCheckpoint(config.model_path,
Exemplo n.º 18
0
#!/usr/bin/python
# -*- coding:utf-8 -*-
import os, cfg, cgi, lib_mod_map, urllib, gettext

gettext.install("mod_mnger", "./locale", unicode=True)

# ошибки в окно, потом закомментить надо
import cgitb

cgitb.enable()

# Определяем пути, см cfg.py
paths = cfg.config("all")
base = paths["base_path"]
modules = paths["mod_path"]
optional = paths["opt_path"]
data_modules = paths["data_mod_path"]
data_optional = paths["data_opt_path"]

# for gettext
title_activate = _("Activating module right here").encode("UTF-8")
title_install = _("Copy module to modules directory and activate it").encode("UTF-8")
activate = _("Activate").encode("UTF-8")
install = _("Install").encode("UTF-8")
cp2modules = _("Copy to MagOS/modules").encode("UTF-8")
cp2data_modules = _("Copy to MagOS-Data/modules").encode("UTF-8")
cp2optional = _("Copy to MagOS/optional").encode("UTF-8")
cp2data_optional = _("Copy to MagOS-Data/optional").encode("UTF-8")
modinfo = _("Module info").encode("UTF-8")

# анализ запроса
import praw, pickle, time, string, text_tools
import numpy as np
from praw.models import MoreComments
from cfg import config
from sys import argv
from progress.bar import IncrementalBar

# We're going to need to log in to reddit. To do so, we'll need a number of text
# arguments that I just store in a private config file, which contains a class with
# attributes which store the things we'll need.
cfg = config()


def get_user_comments(username, reddit, verbose=True):
    #Given a username, get the comments that user has written. Return them as a list
    comments = []

    # There are a number of ways this can go wrong, and as Reddit changes the way the
    # website works, there are bound to be some that pop up which haven't been handled
    # here. This should ensure such situations are handled smoothly.
    try:
        # First get ALL comments by the user.
        user = reddit.redditor(username)
        for c in user.comments.new(limit=None):
            # Then we want to remove any links the user posted in the comment,
            # as well as any text they're quoting from another user. clean_comment does
            # this.
            cc = text_tools.clean_comment(c.body)

            # If the remaining comment is empty, don't do anything, otherwise, keep it.
            if len(cc) > 0: