Exemplo n.º 1
0
	def __init__(self):
		self.n = '\n'
		self.PASSWD_NONE = 0
		self.PASSWD_POTENTIAL = 1
		self.PASSWD_RAR = 2
		s = sites.Sites()
		self.site = s.get()
		try:
			self.stage5limit = self.site['maxnzbsprocessed']
		except KeyError:
			self.site['maxnzbsprocessed'] = 1000
		try:
			self.completion = self.site['releasecompletion']
		except KeyError:
			self.site['releasecompletion'] = 0
		try:
			self.crosspostt = self.site['crossposttime']
		except KeyError:
			self.site['crosspostttime'] = 2
		try:
			if self.site['grabstatus'] == 0:
				self.updategrabs = False
			else:
				self.updategrabs = True
		except KeyError:
			slef.updategrabs = False
Exemplo n.º 2
0
 def __init__(self):
     s = sites.Sites()
     sdata = s.get()
     #self.categorizeforeign = False if site.categorizeforeign == '0' else True
     try:
         self.catlanguage = self.catlanguage
     except:
         self.catlanguage = '0'
Exemplo n.º 3
0
def _redirect():
    """
    Worker redirect to all operations on the DB tables.

    Operates the DB on table specified, for list, add, modify and delete registers.

    It uses the local static variables of the ``worker.py`` script as ``NETOR_HOME_DIRECTORY`` and ``DB_PATH_NAME``,
    unless a full path name to a TinyDB database is specified.

    It supports the following parameters:

    1. specifying operations:

       - l (list)
       - a (add)
       - m (modify)
       - d (delete)

    2. table to operate with

       - customer
       - sites
       - devices

    3. specifying DB full path name

    Example:
    ``../tinydb/scripts/worker.py -l customers /full/path/name/database.json``

    Logging to file ./log/tinydb.log

    :return: nothing
    """

    netorconf.check_netor_config(_NETOR_HOME_DIRECTORY)
    config = configparser.ConfigParser(
        interpolation=configparser.ExtendedInterpolation())
    config.read((_NETOR_HOME_DIRECTORY + "netor/netor.config"))
    tinydb_log_file = config['TinyDB']['tinydb_log_file']

    if (len(sys.argv) == 0) or len(sys.argv) > 4:
        print("\nInvalid parameters. Admin -operation tablename dbfile\n")
        return
    else:
        option = sys.argv[1]
        table = sys.argv[2]

    if len(sys.argv) == 4:
        if os.path.isfile((sys.argv[3])):
            print("Using specified DB file: " + sys.argv[3])
            db_path_name = sys.argv[3]
        else:
            print("DB path or file not found")
            return
    elif len(sys.argv) == 3:
        db_path_name = _DB_PATH_NAME
        print("\nUsing script default DB File: " + db_path_name + "\n")
    else:
        print("\nInvalid parameters. Admin -operation tablename\n")
        return

    if table == "customers":
        x = customers.Customers(db_path_name)
    elif table == "sites":
        x = sites.Sites(db_path_name)
    elif table == "devices":
        x = devices.Devices(db_path_name)
    else:
        print("Invalid table name")
        return

    if option == "-l":
        item = x.list()
        if item:
            netorlogging.log_msg(
                tinydb_log_file, __file__,
                "DB \"" + db_path_name.split("/")[-1] + "\" table \"" + table +
                "\" listed")
    elif option == "-a":
        item = x.add()
        if item:
            netorlogging.log_msg(
                tinydb_log_file, __file__,
                "DB \"" + db_path_name.split("/")[-1] + "\" table \"" + table +
                "\" added \"" + item + "\"")
    elif option == "-m":
        item = x.modify()
        if item:
            netorlogging.log_msg(
                tinydb_log_file, __file__,
                "DB \"" + db_path_name.split("/")[-1] + "\" table \"" + table +
                "\" modified: \"" + item[0] + "\" to \"" + item[1] + "\"")
    elif option == "-d":
        item = x.delete()
        if item:
            netorlogging.log_msg(
                tinydb_log_file, __file__,
                "DB \"" + db_path_name.split("/")[-1] + "\" table \"" + table +
                "\" deleted \"" + item + "\"")
    else:
        print("Invalid class operation")
Exemplo n.º 4
0
#!/usr/bin/env python
# this file is completely temporary
import sites

s = sites.Sites()


class site():
    def __init__(self):
        data = s.get()
        for setting, value in data.iteritems():
            setattr(self, setting, value)
Exemplo n.º 5
0
def writeSetupDoneConfig():
    target = open("/etc/bibbox/conf.d/setup.cfg", 'w')
    target.write('setup="done"')
    target.close()

setupLogger()

sys.stdout.write("Check Vagrant Setup Error. \n")
logger.info("Check Vagrant Setup Error. \n")
setupchecker.Setupchecker(logger)

sys.stdout.write("Trying to connect to liferay server. \n")
logger.info("Trying to connect to liferay server. \n")
testServerStarted(0)

sys.stdout.write("SETUP SITES \n")
logger.info("SETUP SITES \n")
siteService = sites.Sites('20116', logger)
siteService.initSites()

sys.stdout.write("SETUP USERS \n")
logger.info("SETUP USERS \n")
userService = users.Users (companyId = '20116')
userService.initUsers()

api = jsonws.API()

writeSetupDoneConfig()