Beispiel #1
0
    def add_ldap_user(self, data, uname, authenticator_info):
        """Creates LDAP user and adds it to the session if there's at least one group associated with that user.
        :returns: User or None if user was not added."""
        s = db.session
        user_data = self.get_user_data(data)
        user = User(can_change_password=False,
                    active=True,
                    authenticator_info=authenticator_info,
                    **user_data)

        if not user.display_name:
            if user.lastname and user.firstname:
                user.display_name = u"{} {}".format(user.lastname,
                                                    user.firstname)

        added_groups = self.update_groups_from_ldap(user, data)
        if self.auto_create_user == "always" or (
                added_groups and self.auto_create_user == "group"):
            s.add(user)
            logg.info("created ldap user: %s", uname)
            return user

        # no groups found? Don't add user, return None
        logg.info(
            "not creating LDAP user for login '%s' because there's no matching group for this user or\
         or denied by auto_create_user", user.login_name)
Beispiel #2
0
async def profile():
    user_telegram_id = context.user.user_id
    user = User(user_telegram_id)
    amizone = amizone_core.Amizone(user.get_property('username'),
                                   user.get_property('password'))

    profile_information = '\n'.join(amizone.get_profile().values())

    await SendMessage(user_telegram_id, profile_information).send()
Beispiel #3
0
async def update_information():
    user_telegram_id = context.user.user_id
    user = User(user_telegram_id)
    amizone = amizone_core.Amizone(user.get_property('username'),
                                   user.get_property('password'))

    await SendMessage(context.user.user_id, get_translation('process')).send()

    amizone.update()
    await SendMessage(context.user.user_id,
                      get_translation('information_updated')).send()
Beispiel #4
0
async def timetable():
    user_telegram_id = context.user.user_id
    user = User(user_telegram_id)
    amizone = amizone_core.Amizone(user.get_property('username'),
                                   user.get_property('password'))

    timetable_information = amizone.get_timetable()
    msg = '\n'.join([
        ' | '.join(information.values())
        for information in timetable_information
    ])

    await SendMessage(context.user.user_id, msg).send()
Beispiel #5
0
def run(args):
    jobs = []

    user = User(args.domain, args.username, args.password)
    local_ip = retrieveMyIP()

    try:
        targets = listPwnableTargets(args.targets, user)

        logging.warning("%sLet's spray some love... Be patient." %
                        (warningGre))

        for target in targets:
            jobs.append(
                Process(target=sprayLove,
                        args=(user, target, local_ip, args.remove)))
            jobs[-1].start()

        joinThreads(jobs, args.wait)
        logging.warning(
            "\n%sCredentials logged into: %s" %
            (warningGre,
             os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
                          'misc', 'results', 'creds.txt')))

    except KeyboardInterrupt:
        logging.warning("%sKeyboard interrupt. Exiting." % (warningRed))
    except Exception as e:
        logging.warning("%sA problem occurs. Err: %s" % (warningRed, red))
        logging.debug("%s==== STACKTRACE ====" % (blue))
        if logging.getLogger().getEffectiveLevel() <= 10:
            traceback.print_exc(file=sys.stdout)
        logging.debug("%s==== STACKTRACE ====%s" % (blue, white))
    finally:
        exit_gracefully(jobs, 10)
Beispiel #6
0
def run(args):
    jobs = []

    user = User(args.domain, args.username, args.password)
    local_ip = retrieveMyIP()

    try:
        targets = listPwnableTargets(args.targets, user)

        logging.warning("%sExec procdump on targets. Be patients..." %
                        (warningGre))

        for target in targets:
            jobs.append(
                Process(target=sprayLove, args=(user, target, local_ip)))
            jobs[-1].start()

        joinThreads(jobs, 180)  # wait 3 minutes max
        logging.info(
            "\n%sCredentials logged into: %s" %
            (warningGre,
             os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])),
                          'misc', 'results', 'creds.txt')))

    except KeyboardInterrupt:
        logging.warning("%sKeyboard interrupt. Exiting." % (warningRed))
    except Exception as e:
        logging.warning("%sErr: %s" % (warningRed, e))
    finally:
        exit_gracefully(jobs, 10)
Beispiel #7
0
def run(args):
    jobs = []

    user = User(args.domain, args.username, args.password)
    local_ip = retrieveMyIP()

    try:
        targets = listPwnableTargets(args.targets, user)

        logging.warning(
            "%sExec procdump on targets, and retrieve dumps locally into %smisc/dumps%s. Be patients..."
            % (warningGre, green, white))

        for target in targets:
            jobs.append(
                Process(target=sprayLove, args=(user, target, local_ip)))
            jobs[-1].start()

        joinThreads(jobs, 1200)  # wait 20 minutes max
        credentials = parseDumps(dumpDir)

        if credentials is not None:
            print_credentials(credentials)
            write_credentials(credentials)
    except KeyboardInterrupt:
        logging.warning("%sKeyboard interrupt. Exiting." % (warningRed))
    except Exception as e:
        logging.warning("%sErr: %s" % (warningRed, e))
    finally:
        exit_gracefully(jobs, 10, args.keep)
Beispiel #8
0
 def __init__(self, username, f_name, l_name, password, gender, dob,
              tel_number, regular_drugs, prescriptions, nhs_number,
              assigned_gp, verified, feedback, notes, allergies, referral):
     User.__init__(self, username, f_name, l_name, password)
     self.gender = gender
     self.dob = dob
     self.tel_number = tel_number
     self.regular_drugs = regular_drugs
     self.prescriptions = prescriptions
     self.nhs_number = nhs_number
     self.assigned_gp = assigned_gp
     self.verified = verified
     self.feedback = feedback
     self.notes = notes
     self.allergies = allergies
     self.referral = referral
Beispiel #9
0
def signUpUser(user):
    if None not in user.values():
        email, username = user['email'], user['userName']
        emailQuery = User.query.filter_by(email=email).first()
        usernameQuery = User.query.filter_by(username=username).first()
        dbRecordConflict = {
            'emailExists': emailQuery is not None,
            'usernameExists': usernameQuery is not None
        }
        if True in dbRecordConflict.values():
            print(
                f"There is a record containing username, and/or email: {dbRecordConflict}"
            )
            return {'error': True, 'message': dbRecordConflict}
        else:
            firstName, lastName, password = user['firstName'], user[
                'lastName'], user['password']
            newUser = User(firstName, lastName, username, email,
                           getHashedPass(password))
            db.session.add(newUser)
            db.session.commit()
            print(f"newly created user: {newUser}")
            return {'error': False, 'message': f'new user id: {newUser.id}'}
    else:
        return {'error': True, 'message': 'invalid payload'}
Beispiel #10
0
 def delete_user(self, username, ext_id=0):
     user = User.by_name(username, False)
     if not user:
         raise UserError('User %s not found' % username)
     if ext_id:
         if user.external_id != ext_id:
             raise UserError('Invalid external id for user %s' % username)
     user.delete()
Beispiel #11
0
async def auth():
    user_telegram_id = context.user.user_id
    user = User(user_telegram_id)

    await SendMessage(user_telegram_id,
                      get_translation('enter_amizone_username')).send()
    yield next()

    username = context.message.text
    user.set_property('username', username)

    await SendMessage(user_telegram_id,
                      get_translation('got_username').format(username)).send()

    await SendMessage(user_telegram_id,
                      get_translation('enter_amizone_password')).send()
    yield next()

    password = context.message.text
    user.set_property('password', password)

    await SendMessage(user_telegram_id,
                      get_translation('got_password').format(password)).send()
    await SendMessage(user_telegram_id,
                      get_translation('got_password').format(password)).send()

    login = amizone_core.Amizone(user.get_property('username'),
                                 user.get_property('password'))

    if login:
        msg = get_translation('logged')
    else:
        msg = get_translation('went_wrong')

    await SendMessage(user_telegram_id, msg).send()
Beispiel #12
0
    def add_ldap_user(self, data, uname, authenticator_info):
        """Creates LDAP user and adds it to the session if there's at least one group associated with that user.
        :returns: User or None if user was not added."""
        s = db.session
        user_data = self.get_user_data(data)
        user = User(can_change_password=False, active=True, authenticator_info=authenticator_info, **user_data)

        if not user.display_name:
            if user.lastname and user.firstname:
                user.display_name = u"{} {}".format(user.lastname, user.firstname)

        added_groups = self.update_groups_from_ldap(user, data)
        if self.auto_create_user == "always" or (added_groups and self.auto_create_user == "group"):
            s.add(user)
            logg.info("created ldap user: %s", uname)
            return user

        # no groups found? Don't add user, return None
        logg.info("not creating LDAP user for login '%s' because there's no matching group for this user or\
         or denied by auto_create_user", user.login_name)
Beispiel #13
0
def users_and_groups_for_ruleset(session, internal_authenticator_info):
    from core import User, UserGroup

    users = [
        User(login_name=u"darfdas",
             authenticator_info=internal_authenticator_info)
    ]
    session.add_all(users)

    groups = [
        UserGroup(name=u"test_readers"),
        UserGroup(name=u"test_readers2")
    ]
    session.add_all(groups)
    return users, groups
Beispiel #14
0
async def main():

    async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(
            force_close=True)) as session:

        logger.info('Start generating users...')
        tasks = [
            asyncio.ensure_future(
                User.generate(
                    session,
                    max_posts=random.randint(0, RULES['max_user_posts']),
                    max_likes=random.randint(0, RULES['max_user_likes']),
                )) for _ in range(RULES['users'])
        ]

        logger.info('Waiting for content generation...')
        # Start simulation right after release of each task
        await asyncio.gather(*[
            asyncio.ensure_future(simulate_when_done(awaited_user))
            for awaited_user in tasks
        ])

        logger.info('Simulation ended successfully...')
Beispiel #15
0
# -*- coding: utf-8 -*-

#%% Definition of the inputs
'''
Input data definition 
'''


from core import User, np
User_list = []


#Create new urban user classes
LMIU = User("low-middle income urban",100)
User_list.append(LMIU)


#Create new appliances

#Low-Middle Income Urban

LMIU_light_bulb = LMIU.Appliance(LMIU,4,20,3,120,0.2,10)
LMIU_light_bulb.windows([18*60,24*60],[0,30],0.35,[6*60,8*60])

LMIU_Radio = LMIU.Appliance(LMIU,1,10,2,60,0.1,5)
LMIU_Radio.windows([6*60+30,9*60],[18*60,21*60],0.35)

LMIU_Stereo = LMIU.Appliance(LMIU,1,50,2,30,0.2,10)
LMIU_Stereo.windows([12*60,15*60],[18*60,24*60],0.35)

LMIU_TV = LMIU.Appliance(LMIU,1,70,2,90,0.1,5)
Beispiel #16
0
# -*- coding: utf-8 -*-

#%% Definition of the inputs
'''
Input data definition 
'''


from core import User, np
User_list = []


#Create new rural user classes

HMI = User("higher middle income",100)
User_list.append(HMI)


#Create new appliances

#High-Middle Income
HMI_light_bulb = HMI.Appliance(HMI,4,20,3,120,0.2,10)
HMI_light_bulb.windows([18*60,24*60],[0,30],0.35,[6*60,8*60])

# HMI_Fan = HMI.Appliance(HMI,2,50,2,300,0.2,15)
# HMI_Fan.windows([10*60,18*60],[0,0],0.35)

HMI_TV = HMI.Appliance(HMI,1,70,2,90,0.1,5)
HMI_TV.windows([12*60,15*60],[18*60,24*60],0.35)

HMI_DVD = HMI.Appliance(HMI,1,20,2,60,0.1,5,occasional_use = 0.33)
Beispiel #17
0
# -*- coding: utf-8 -*-

#%% Definition of the inputs
'''
Input data definition 
'''


from core import User, np
User_list = []


#Create new rural user classes

MC = User("Medical Clinic",1)
User_list.append(MC)

# Medical Clinic: Most private clinics in the community are run by nurses.

#Create new appliances

MC_light_bulb = MC.Appliance(MC,10,60,1,600,0.2,30)
MC_light_bulb.windows([0,1440],[0,0],0.35)

MC_Phone_charger = MC.Appliance(MC,6,5,1,120,0.2,30)
MC_Phone_charger.windows([480,1200],[0,0],0.35)

MC_VHF_Radio = MC.Appliance(MC,1,7,1,1440,0,1440, fixed='yes', flat='yes')
MC_VHF_Radio.windows([0,1440],[0,0],0.0)

MC_Vaccine_Refrigerator = MC.Appliance(MC,1,250,1,1440,0,30)
Beispiel #18
0
    while op != 0:
        # Add movie
        if op == 1:
            id = input('Digite o código do filme? ')
            name = input('Digite o nome do filme? ')
            year = int(input('Digite o ano do filme? '))
            movie = Movie(id, name, year)

            store.addMovie(movie)

        # Add user
        elif op == 2:
            id = input('Digite o código do usuário? ')
            name = input('Digite o nome do usuário? ')
            phone = input('Digite o telefone do usuário? ')
            user = User(id, name, phone)

            store.addUser(user)

        # Rent
        elif op == 3:
            user = None
            while user == None:
                userId = input('Digite o código do usuário: ')
                user = store.searchUser(userId)

                if user == None:
                    print('Usuário não econtrado!')

            movie = None
            while movie == None:
Beispiel #19
0
'''


from core import User, np
User_list = []

'''
This example input file represents an whole village-scale community,
adapted from the data used for the Journal publication. It should provide a 
complete guidance to most of the possibilities ensured by RAMP for inputs definition,
including specific modular duty cycles and cooking cycles. 
For examples related to "thermal loads", see the "input_file_2".
'''

#Create new urban user classes
HMIU = User("high-middle income urban",100)
User_list.append(HMIU)


#Create new appliances

#High Middle Income Urban
HMIU_light_bulb = HMIU.Appliance(HMIU,5,20,2,120,0.2,10)
HMIU_light_bulb.windows([1170,1440],[0,30],0.35)

HMIU_CFL = HMIU.Appliance(HMIU,3,8,2,120,0.2,10)
HMIU_CFL.windows([1170,1440],[0,30],0.35)

HMIU_Fan = HMIU.Appliance(HMIU,1,50,2,300,0.2,15, occasional_use = 0.4)
HMIU_Fan.windows([8*60,11*60],[18*60,22*60],0.35)
Beispiel #20
0
Hot months: [0,0],[0,0],[0,1400],[0,0],[0,0],[0,0] Aug
Warm months: [0,0],[0,0],[480,1200],[0,0],[0,299],[1201,1440] feb,march,apr,jun,july,nov,dec
Cold months: [0,0],[0,0],[301,1200],[0,0],[0,299],[1201,1440] Jan,sep
Rainny months: [0,0],[0,0],[480,1200],[0,0],[0,299],[1201,1440] oct 


Feb-Oct: Schools*
Mixer IN the HI just on the January
2 Freezer in the HI runs on the spring (Oct-Dec)
'''

from core import User, np
User_list = []
#User classes definition

HI = User("high income", 0)
User_list.append(HI)

LI = User("low income", 1)
User_list.append(LI)

#High-Income
#indoor bulb
HI_indoor_bulb = HI.Appliance(HI, 3, 7, 1, 320, 0.6, 190)
HI_indoor_bulb.windows([1080, 1440], [0, 0])
#outdoor bulb

HI_outdoor_bulb = HI.Appliance(HI, 1, 13, 1, 340, 0.1, 300)
HI_outdoor_bulb.windows([1100, 1440], [0, 0])

HI_Radio = HI.Appliance(HI, 1, 7, 1, 280, 0.3, 110)
Beispiel #21
0
 def _check_user(self, username):
     user = User.by_name(username, False)
     if not user:
         raise UserError('Invalid user %s' % username)
     return user
Beispiel #22
0
# -*- coding: utf-8 -*-

# 09 April 2020
# Nicolò Stevanato - Politecnico di Milano - Fondazione Eni Enrico Mattei

#%% Definition of the inputs

from core import User, np
User_list = []
'''
This File contains the average appliances that charcterize a rural Health Centre in Kenya, according to PoliMi field campaign - 2020
'''

#Create new user classes

Healthcenter = User("HealthCenter", 1)
User_list.append(Healthcenter)

#Create new appliances

HC_indoor_bulb = Healthcenter.Appliance(Healthcenter, 27, 12, 1, 540, 0.2, 300)
HC_indoor_bulb.windows([300, 1320], [0, 0], 0.35)

HC_indoor_tubes = Healthcenter.Appliance(Healthcenter, 38, 30, 1, 540, 0.2,
                                         300)
HC_indoor_tubes.windows([300, 1320], [0, 0], 0.35)

HC_outdoor_bulb = Healthcenter.Appliance(Healthcenter,
                                         6,
                                         30,
                                         2,
Beispiel #23
0
 def create_user(self, username, ext_id):
     exist = User.by_name(username, False)
     if exist:
         raise UserError('User %s already exist' % username)
     user = User.create(name=username, external_id=ext_id)
     return user.eid
Beispiel #24
0
# -*- coding: utf-8 -*-

#%% Definition of the inputs
'''
Input data definition (this is planned to be externalised in a yaml or similar file)
'''

from core import User
from initialise import User_list

#%%User classes definition

HI = User("high income", 11)
User_list.append(HI)

#Appliances definition

#High-Income
HI_indoor_bulb = HI.Appliance(HI, 6, 7, 2, 120, 0.2, 10)
HI_indoor_bulb.windows([1107, 1440], [0, 30], 0.35)

HI_outdoor_bulb = HI.Appliance(HI, 2, 13, 2, 600, 0.2, 10)
HI_outdoor_bulb.windows([0, 330], [1107, 1440], 0.35)

HI_TV = HI.Appliance(HI, 2, 60, 3, 180, 0.1, 5)
HI_TV.windows([720, 900], [1107, 1440], 0.35, [0, 60])

HI_Phone_charger = HI.Appliance(HI, 5, 2, 2, 300, 0.2, 5)
HI_Phone_charger.windows([1110, 1440], [0, 30], 0.35)

HI_Freezer = HI.Appliance(HI, 1, 200, 1, 1440, 0, 30, 'yes', 3)
Beispiel #25
0
 def get_user(self, username):
     user = User.by_name(username, False)
     if not user:
         raise UserError('User %s not found' % username)
     return user
Hot months: [0,0],[0,0],[0,1400],[0,0],[0,0],[0,0] Aug
Warm months: [0,0],[0,0],[480,1200],[0,0],[0,299],[1201,1440] feb,march,apr,jun,july,nov,dec
Cold months: [0,0],[0,0],[301,1200],[0,0],[0,299],[1201,1440] Jan,sep
Rainny months: [0,0],[0,0],[480,1200],[0,0],[0,299],[1201,1440] oct 


Feb-Oct: Schools*
Mixer IN the HI just on the January
2 Freezer in the HI runs on the spring (Oct-Dec)
'''

from core import User, np
User_list = []
#User classes definition

HI = User("high income", 1)
User_list.append(HI)

LI = User("low income", 0)
User_list.append(LI)
'''

Base scenario (BSA): Indoor bulb (3), outdoor bulb (1), radio (1), tv (1), phone charger (2), Water Heater (1), Mixer (1)
Base scenario (B): Indoor bulb (3), outdoor bulb (1), radio (1), tv (1), phone charger (2)

A
Scenario 1: BSA + Fridge (1) + Freezer* (1).
Scenario 2: BSA + Fridge (1).
Scenario 3: BSA + Fridge (1)*.
Scenario 4: BSA + Freezer (1).
Scenario 5: BSA + Wheler (1).
Beispiel #27
0
# -*- coding: utf-8 -*-

#%% Definition of the inputs
'''
Input data definition 
'''

from core import User, np
User_list = []

#Create new rural user classes
HI = User("high income", 100)
User_list.append(HI)

#Create new appliances

#High-Income
HI_light_bulb = HI.Appliance(HI, 6, 20, 3, 120, 0.2, 10)
HI_light_bulb.windows([18 * 60, 24 * 60], [0, 30], 0.35, [6 * 60, 8 * 60])

HI_Fan = HI.Appliance(HI, 2, 50, 2, 300, 0.2, 15, occasional_use=0.2)
HI_Fan.windows([9 * 60, 21 * 60], [0, 0], 0.35)

HI_TV = HI.Appliance(HI, 2, 70, 2, 90, 0.1, 5)
HI_TV.windows([12 * 60, 15 * 60], [18 * 60, 24 * 60], 0.35)

HI_Radio = HI.Appliance(HI, 1, 10, 2, 60, 0.1, 5)
HI_Radio.windows([6 * 60 + 30, 9 * 60], [18 * 60, 21 * 60], 0.35)

HI_DVD = HI.Appliance(HI, 1, 20, 2, 60, 0.1, 30)
HI_DVD.windows([0, 0], [18 * 60, 24 * 60], 0.35)
Beispiel #28
0
# -*- coding: utf-8 -*-

# 09 April 2020
# Nicolò Stevanato - Politecnico di Milano - Fondazione Eni Enrico Mattei

#%% Definition of the inputs

from core import User, np
User_list = []
'''
This File contains the average appliances that charcterize a rural Health Centre in Kenya, according to PoliMi field campaign - 2020
'''

#Create new user classes

School = User("school", 1)
User_list.append(School)

#Create new appliances

S_indoor_bulb = School.Appliance(School,
                                 90,
                                 12,
                                 2,
                                 360,
                                 0.2,
                                 120,
                                 wd_we_type=0)
S_indoor_bulb.windows([420, 600], [840, 1020], 0.2)

S_indoor_tubes = School.Appliance(School,
Beispiel #29
0
@author: alejandrosoto
Script for 2 class of household in Raqaypampa.

"""

# -*- coding: utf-8 -*-
"""

@author: Alejandro Soto
"""

from core import User, np
User_list = []
#User classes definition

HI = User("high income", 1)
User_list.append(HI)

LI = User("low income", 0)
User_list.append(LI)

#High-Income
#indoor bulb
HI_indoor_bulb = HI.Appliance(HI, 3, 7, 1, 320, 0.6, 190)
HI_indoor_bulb.windows([1080, 1440], [0, 0])

#outdoor bulb
HI_outdoor_bulb = HI.Appliance(HI, 1, 13, 1, 340, 0.1, 300)
HI_outdoor_bulb.windows([1100, 1440], [0, 0])

#Radio
Beispiel #30
0
@author: alejandrosoto
Script for 2 class of household in Raqaypampa.

"""

# -*- coding: utf-8 -*-
"""

@author: Alejandro Soto
"""

from core import User, np
User_list = []
#User classes definition

HI = User("high income", 0)
User_list.append(HI)

LI = User("low income", 1)
User_list.append(LI)

#A
#indoor bulb
HI_indoor_bulb = HI.Appliance(HI, 3, 7, 1, 320, 0.6, 190)
HI_indoor_bulb.windows([1080, 1440], [0, 0])
#outdoor bulb

HI_outdoor_bulb = HI.Appliance(HI, 1, 13, 1, 340, 0.1, 300)
HI_outdoor_bulb.windows([1100, 1440], [0, 0])

HI_Radio = HI.Appliance(HI, 1, 7, 1, 280, 0.3, 110)
Beispiel #31
0
# 09 April 2020
# Nicolò Stevanato - Politecnico di Milano - Fondazione Eni Enrico Mattei

#%% Definition of the inputs

from core import User, np
User_list = []

'''
This File contains the average appliances that charcterize a SubCounty Hospital in Kenya, according to PoliMi field campaign - 2020
'''

#Create new user classes

SCHospital = User("SCHospital",1)
User_list.append(SCHospital)


#Create new appliances

SCH_indoor_bulb = SCHospital.Appliance(SCHospital, 60,12,1,960,0.2,720)
SCH_indoor_bulb.windows([0,1440],[0,0],0)

SCH_indoor_tubes = SCHospital.Appliance(SCHospital, 60,30,1,960,0.2,720)
SCH_indoor_tubes.windows([0,1440],[0,0],0)

SCH_outdoor_bulb = SCHospital.Appliance(SCHospital,20,30,2,720,0,720, 'yes', flat = 'yes')
SCH_outdoor_bulb.windows([0,360],[1080,1440],0)

SCH_radio = SCHospital.Appliance(SCHospital,6,7,1,300,0.2,180)
"""


# -*- coding: utf-8 -*-
"""

@author: Alejandro Soto
"""


from core import User, np
User_list = []
#User classes definition

HI = User("high income",0)
User_list.append(HI)


LI = User("low income",1)
User_list.append(LI)



#High-Income
#indoor bulb
HI_indoor_bulb = HI.Appliance(HI,3,7,1,320,0.6,190)
HI_indoor_bulb.windows([1080,1440],[0,0])
#outdoor bulb

HI_outdoor_bulb = HI.Appliance(HI,1,13,1,340,0.1,300)
Beispiel #33
0
# -*- coding: utf-8 -*-

# 09 April 2020
# Nicolò Stevanato - Politecnico di Milano - Fondazione Eni Enrico Mattei

#%% Definition of the inputs

from core import User, np
User_list = []
'''
This File contains the average appliances that charcterize a rural Dispensary in Kenya, according to PoliMi field campaign - 2020
'''

#Create new user classes

Dispensary = User("Dispensary", 1)
User_list.append(Dispensary)

#Create new appliances

Di_indoor_bulb = Dispensary.Appliance(Dispensary,
                                      11,
                                      12,
                                      1,
                                      300,
                                      0.2,
                                      120,
                                      wd_we_type=0)
Di_indoor_bulb.windows([480, 1020], [0, 0], 0.2)

Di_indoor_tubes = Dispensary.Appliance(Dispensary,
Beispiel #34
0
 def test_can_create_user(self):
     _user = User("John Doe", "*****@*****.**")
     self.assertEqual(_user.name, "John Doe")
     self.assertEqual(_user.email, "*****@*****.**")
Beispiel #35
0
# -*- coding: utf-8 -*-

#%% Definition of the inputs
'''
Input data definition 
'''

from core import User, np
User_list = []

#Create new rural user classes

MI = User("middle income", 100)
User_list.append(MI)

#Create new appliances

#Middle-Income
MI_light_bulb = MI.Appliance(MI, 3, 20, 3, 120, 0.2, 10)
MI_light_bulb.windows([18 * 60, 24 * 60], [0, 30], 0.35, [6 * 60, 8 * 60])

MI_Radio = MI.Appliance(MI, 1, 10, 2, 60, 0.1, 5)
MI_Radio.windows([6 * 60 + 30, 9 * 60], [18 * 60, 21 * 60], 0.35)

MI_TV = MI.Appliance(MI, 1, 70, 2, 90, 0.1, 5)
MI_TV.windows([0, 0], [18 * 60, 24 * 60], 0.35)

MI_Fan = MI.Appliance(MI, 1, 50, 2, 300, 0.2, 15, occasional_use=0.8)
MI_Fan.windows([7 * 60, 9 * 60], [17 * 60, 20 * 60], 0.35)

MI_Phone_charger = MI.Appliance(MI, 2, 7, 2, 240, 0.2, 10)