Exemplo n.º 1
0
def main():
  parser = ArgumentParser(prog='logfire', usage='%(prog)s [options]')

  parser.add_argument('--listen',
    help="Listen for log messages published on Redis channel 'logfire'",
    nargs='?', default=False, const=True)
  parser.add_argument('--serve',
    help="Run HTTP server to analyze logs from browser",
    nargs='?', default=False, const=True)
  parser.add_argument('--tail',
    help="Tail logs",
    nargs='?', default=False, const=True)
  parser.add_argument('--mongohost',
    help="hostname:port for MongoDB")

  parser.add_argument('-p','--port', help="Port for --serve",
    type=int, default=7095)
  parser.add_argument('--comp', help="Component filter for --tail")

  parser.add_argument('--cookiesecret',
    help="Cookie secret if authentication is enabled")
  parser.add_argument('--authgmaillist',
    help="Comma separated list of gmail accounts authorized to access")

  args = parser.parse_args()

  if args.listen:
    listen(args)
  elif args.serve:
    serve(args)
  elif args.tail:
    tail(args)
  else:
    parser.print_help()
def get_last_controller_events(num_events, controller_ids):
    log_file = open(LOG_PATH, 'r')
    lines = tail(log_file, num_events)

    new_events = []

    for line in lines:
        line = line.strip()
        components = line.split(' ')

        if len(components) != 18:
            continue

        if components[1] in received_events:
            continue

        received_events.append(components[1])

        if components[10] == '05' and components[11] == '5B':  # Central scene command class?
            request_bytes = components[4:17]
            if request_bytes[5] in controller_ids:
                new_event = ZWaveRCVDLogEvent(request_bytes)
                new_events.append(new_event)
                print(request_bytes)

    log_file.close()

    if len(new_events) > 0:
        return new_events

    return None
Exemplo n.º 3
0
 def run(self):
     for line in tail(self.fname):
         try:
             match = self.regex.match(line)
             self.redis.lpush('data', match.group('protocol'))
         except AttributeError:
             print >>sys.stderr, line,
Exemplo n.º 4
0
def req_tail():
    _watchDog.wake()
    f = open(_watchDog.LOG_FILE)
    if (f):
        result = tail(f)
        f.close()
        return result
    else:
        return ""
    def getPos(watchID,line = 1):
        session = watch.fetch(watchID)
        if session[0] == 0:
            filename = watch.noSessionFile
        else :
            filename = session[2]

        logFile = path.join(wDir,watchID,filename+watchManager.logEXT)
        
        from tail import tail
        return tail(logFile,line)
def getNewAlert():
    from tail import tail
    from setting import alert_log, t_format
    from datetime import datetime, timedelta

    alertLog = tail(alert_log,30,[0,1,2,3])

    nearTime = datetime.now() - timedelta(minutes=30)
    nearTimeStr = format(nearTime, t_format)
    print(nearTimeStr)

    nearAlert = []
    for alert in alertLog:
        if alert[0] > nearTimeStr:
            nearAlert.append(alert)


    return json.dumps(nearAlert)
Exemplo n.º 7
0
def test_tail_arg_gt_num_lines_files(my_file):
    # n of > file length basically gets the whole file, but need to do some
    # byte to str conversion and strip off last line's newline char
    actual = tail(my_file.resolve(), 10)
    expected = [line.decode("utf-8") for line in content.splitlines()]
    assert actual == expected
Exemplo n.º 8
0
from argparse import ArgumentParser
import glob
import numpy as np
from tail import tail

if __name__ == '__main__':
    parser = ArgumentParser()

    parser.add_argument('--nwalkers', metavar='N', default=100, type=int, help='number of walkers')

    args = parser.parse_args()

    for f in glob.glob('chain.[0-9][0-9].dat'):
        with open(f, 'r') as inp:
            header = inp.readline()
            lines = tail(inp, args.nwalkers)

        with open(f, 'w') as out:
            out.write(header)
            for l in lines:
                out.write(l) # Comes with '\n'

    for f in glob.glob('chain.[0-9][0-9].lnlike.dat') + glob.glob('chain.[0-9][0-9].lnpost.dat'):
        with open(f, 'r') as inp:
            header = inp.readline()
            lines = tail(inp, 1)

        with open(f, 'w') as out:
            out.write(header + '\n')
            out.write(lines[0])
Exemplo n.º 9
0
 def test_string(self):
     self.assertEqual(tail('hello', 2), ['l', 'o'])
Exemplo n.º 10
0
 def test_n_larger_than_iterable_length(self):
     nums = [1, 2, 3, 4]
     self.assertEqual(tail(nums, 5), [1, 2, 3, 4])
     self.assertEqual(tail([], 10), [])
Exemplo n.º 11
0
 def test_two(self):
     self.assertEqual(tail([1, 2], 2), [1, 2])
Exemplo n.º 12
0
 def test_one(self):
     self.assertEqual(tail([1, 2], 1), [2])
Exemplo n.º 13
0
 def test_iterator(self):
     nums = (n**2 for n in [1, 2, 3, 4])
     self.assertEqual(tail(nums, -1), [])
     self.assertEqual(tail(nums, 2), [9, 16])
     self.assertEqual(tail(nums, 0), [])
     self.assertEqual(tail(nums, 1), [])
Exemplo n.º 14
0
 def test_string(self):
     self.assertEqual(tail("hello", 2), ["l", "o"])
Exemplo n.º 15
0
def getAlert(num):
    from tail import tail
    from setting import alert_log

    alertLog = tail(alert_log,num,[0,1,2,3])
    return json.dumps(alertLog)
Exemplo n.º 16
0
	    if not args['calleridani']:
		return
	    app_uniqid = args['uniqueid']
	    if app_uniqid in self._calls:
		    self._calls[app_uniqid].on_hangup(args)
		    del self._calls[app_uniqid]
	    self.write("hangup: " + " " + str(args) + " " + str(args['uniqueid']))

    def on_answer(self, args):
	    app_uniqid = args['linkedid']
	    if app_uniqid in self._calls:
		    res = self._calls[app_uniqid].on_answer(args)
		    if res == False:
			print "deleting from congestion"
			del self._calls[app_uniqid]
	    self.write("answer: " + str(args) + " " + args['uniqueid'])

if __name__ == '__main__':
	from tail import tail
	from time import sleep
	m = CallManager()
	
	m.on_text('"HANGUP","1354410942.161893","","701","","","","","from-payuser","SIP/1.0.0.9-00000001","AppDial","(Outgoing Line)","3","0.0","1354410928.1","1354410928.0","","","","16,SIP/1.0.0.9-00000001,"')
	
	t = tail(filename, m.on_text)
	while True:
		t.process()
		sleep(1)


Exemplo n.º 17
0
 def test_tuple(self):
     self.assertEqual(tail((1, 2, 3), 3), [1, 2, 3])
s.push(['Dollar', 3, 4])
print 'Länge des Stacks', s.lenght()
print 'Element1', s.pop()
print 'Element2', s.pop()
print 'Länge des Stacks', s.lenght()
del s

### EXCEPTIONS ###
#try:
#	f = open("file_unknown.txt", "r")
#except IOError as e:
#	print e

# man kann auch selbst exceptions werfen
#raise RuntimeError("This is wrong")

# http://docs.python.org/2/library/exceptions.html Liste eingebauter Exceptiontypen und deren Hirarchie

### MODULE ###
# -> sind Auslagerungen von Klassen oder Funktionsdefinitionen die man importieren kann
import tail
print dir(tail)

# enthaltene Funktionen oder Klassen werden dann ganz normal benutzte
wwwlog = tail.tail(open('portfolio.csv'))
pylines = tail.grep(wwwlog, 'GOOG')
#for line in pylines:
#	print line;

# from tail import grep #um spezifische verweise zu importieren spart dann tail. ein
Exemplo n.º 19
0
 def test_negative_n(self):
     nums = [1, 2, 3, 4]
     self.assertEqual(tail(nums, -1), [])
     self.assertEqual(tail((), -9), [])
Exemplo n.º 20
0
def check_logs ():
    for log_file in log_files:
        codes = {"ok":0, "error":0}
        try:
            f = file("lastupdate.txt")
            last_modified_on = f.read()
            f.close()
        except:
            last_modified_on = ""        
        

        ls = tail.tail(log_file, 1000)
        first_time = None
        last_time = ""
        for i in range(1, len(ls)):
            l = ls[-i]
            if l.startswith("201"):            
                modified_on = l[0:19]
                f = file("lastupdate.txt", "w")
                f.write(modified_on)
                f.close()
                
                modified_on = datetime.datetime.strptime(modified_on, "%Y-%m-%d %H:%M:%S")
                modified_on = time.mktime(modified_on.timetuple())

                break


        codes["modified_on"] = int(modified_on) +28800
        print codes["modified_on"]
        time_takens = []

        total = len(ls)
        for l in ls:
            if l.startswith("201") and l[0:19] > last_modified_on:
                data = l.split(" ")
                if not first_time:
		            first_time = l[0:19]
                
                last_time = l[0:19]

                try:
                    code = data[-3]
                    code = int(code)
                    if code < 400:
                        add(codes, "ok")
                    else:
                        add(codes, "error")

                    time_taken = int(data[-1])
                    time_takens.append(time_taken)
                except:
                    pass

        cpu = get_cpu_load()
        if cpu >= max_usage:
            time.sleep(2)
            cpu = get_cpu_load()

        codes["cpu"] = cpu
        codes["date"] = time.strftime("%Y-%m-%d %H:%M:%S")
        if len(time_takens) > 0:        
            codes["max_time"] = max(time_takens)
            codes["min_time"] = min(time_takens)
            codes["avg_time"] = sum(time_takens) /  len(time_takens)
            codes["requests"] = len(time_takens)
            first_time = datetime.datetime.strptime(first_time, "%Y-%m-%d %H:%M:%S")
            last_time = datetime.datetime.strptime(last_time, "%Y-%m-%d %H:%M:%S")
            duration = last_time - first_time
            codes["requests"] = len(time_takens) / duration.seconds


        data = str(codes).replace("'", '"')
        f = file(sys.argv[2], "w+")
        f.write(data)
        f.close()

        print data

        logs = file(d.isoformat() + ".log", "a")
        logs.write(data)
        logs.write("\n")
        logs.close()

        has_error = False
        if codes["error"] > 200 or codes["avg_time"] > 1000 or codes["requests"] < 2 or codes["cpu"] > 85:
            has_error = True
        f = file("update.bat", "w+")
        if has_error:
            #f.write("iisapp /a mobileshabik.morange.com /r")

            logs = file("errlog" + str(modified_on) + ".log", "w+")
            logs.writelines(ls)
            logs.close()
        f.write("\n")
        f.write("update_stat.bat")
        f.close()

        rate = float(codes["ok"]) / (float(codes["ok"]) + float(codes["error"]))
        url = "http://angel:8080/rrd?rrd=mobileweb163&ds=online&v=%s&v=%s&v=%s&v=%s" % (str(rate), str(codes["cpu"]), str(codes["avg_time"]), str(codes["requests"]))
        print url

        fetch_page(url)
Exemplo n.º 21
0
 def test_zero(self):
     self.assertEqual(tail([1, 2], 0), [])
Exemplo n.º 22
0
def empty(vehicle):
    """ weight = SUAVE.Methods.Weights.Correlations.Solar_HPA_weights.empty(wing,aircraft,horizontal,vertical): 
            
        Inputs:
            wing - a data dictionary with the fields:
                Sw -       wing area [m**2]
                bw -       wing span [m]
                cw -       average wing chord [m]
                deltaw -   average rib spacing to average chord ratio
                Nwr -      number of wing surface ribs (bw**2)/(deltaw*Sw)
                t_cw -     wing airfoil thickness to chord ratio
                Nwer -     number of wing end ribs (2*number of individual wing panels -2)
                
            horizontal - a data dictionary with the fields:
                Sts -      tail surface area (m)
                bts -      tail surface span (m)
                cts -      average tail surface chord (m)
                deltawts - average rib spacing to average chord ratio
                Ntsr -     number of tail surface ribs (bts^2)/(deltats*Sts)
                t_cts -    tail airfoil thickness to chord ratio
                
            vertical - a data dictionary with the fields:
                Sts -      tail surface area (m)
                bts -      tail surface span (m)
                cts -      average tail surface chord (m)
                deltawts - average rib spacing to average chord ratio
                Ntsr -     number of tail surface ribs (bts**2)/(deltats*Sts)
                t_cts -    tail airfoil thickness to chord ratio
                
            aircraft - a data dictionary with the fields:    
                nult -     ultimate load factor
                GW -       aircraft gross weight
                qm -       dynamic pressure at maneuvering speed (N/m2)
                Ltb -      tailboom length (m)
        
            Outputs:
                Wws -      weight of wing spar (kg)
                Wtss -     weight of tail surface spar (kg)
                Wwr -      weight of wing ribs (kg)
                Wtsr -     weight of tail surface ribs (kg)
                Wwer -     weight of wing end ribs (kg)
                WwLE -     weight of wing leading edge (kg)
                WtsLE -    weight of tail surface leading edge (kg)
                WwTE -     weight of wing trailing edge (kg)
                Wwc -      weight of wing covering (kg)
                Wtsc -     weight of tail surface covering (kg)
                Wtb -      tailboom weight (kg)
                    
            Assumptions:
                All of this is from AIAA 89-2048, units are in kg. These weight estimates
                are from the MIT Daedalus and are valid for very lightweight
                carbon fiber composite structures. This may need to be solved iteratively since
                gross weight is an input.
                
        """
    
    #Unpack
    
    nult   = vehicle.envelope.ultimate_load
    gw     = vehicle.mass_properties.max_takeoff
    qm     = vehicle.qm
    
    # Wing weight
    if not vehicle.wings.has_key('Main Wing'):
        wt_wing = 0.0
        warnings.warn("There is no Wing Weight being added to the Configuration", stacklevel=1)
    else:
        Sw      = vehicle.wings['Main Wing'].areas.reference
        bw      = vehicle.wings['Main Wing'].spans.projected
        cw      = vehicle.wings['Main Wing'].chords.mean_aerodynamic
        Nwr     = vehicle.wings['Main Wing'].number_ribs
        t_cw    = vehicle.wings['Main Wing'].thickness_to_chord
        Nwer    = vehicle.wings['Main Wing'].number_end_ribs
        wt_wing = wing.wing(Sw,bw,cw,Nwr,t_cw,Nwer,nult,gw)
        vehicle.wings['Main Wing'].mass_properties.mass = wt_wing
    
    # Horizontal Tail weight
    if not vehicle.wings.has_key('Horizontal Stabilizer'):
        wt_ht = 0.0
        warnings.warn("There is no Horizontal Tail Weight being added to the Configuration", stacklevel=1)
    else:      
        S_h    = vehicle.wings['Horizontal Stabilizer'].areas.reference
        b_h    = vehicle.wings['Horizontal Stabilizer'].spans.projected
        chs    = vehicle.wings['Horizontal Stabilizer'].chords.mean_aerodynamic
        Nhsr   = vehicle.wings['Horizontal Stabilizer'].number_ribs
        t_ch   = vehicle.wings['Horizontal Stabilizer'].thickness_to_chord
        wt_ht  = tail.tail(S_h,b_h,chs,Nhsr,t_ch,qm)
        vehicle.wings['Horizontal Stabilizer'].mass_properties.mass = wt_ht
    
    # Vertical Tail weight
    if not vehicle.wings.has_key('Vertical Stabilizer'):   
        wt_vt = 0.0
        warnings.warn("There is no Vertical Tail Weight being added to the Configuration", stacklevel=1)    
    else:    
        S_v    = vehicle.wings['Vertical Stabilizer'].areas.reference
        b_v    = vehicle.wings['Vertical Stabilizer'].spans.projected
        cvs    = vehicle.wings['Vertical Stabilizer'].chords.mean_aerodynamic
        Nvsr   = vehicle.wings['Vertical Stabilizer'].number_ribs
        t_cv   = vehicle.wings['Vertical Stabilizer'].thickness_to_chord
        wt_vt   = tail.tail(S_v,b_v,cvs,Nvsr,t_cv,qm)
        vehicle.wings['Vertical Stabilizer'].mass_properties.mass = wt_vt

    ##Fuselage weight
    #Ltb     = vehicle.Ltb  
    #wt_tb   = fuselage.fuselage(S_h,qm,Ltb)
    #vehicle.Fuselages.Fuselage.mass_properties.mass = wt_tb
    
    weight                 = Data()
    weight.wing            = wt_wing
    #weight.fuselage        = wt_tb
    weight.horizontal_tail = wt_ht
    weight.vertical_tail   = wt_vt
    
    return weight
    
    
    
    
    
    
    
    
    
    def run(self):
        '''Creates required directories, base_dir at ~/cluster_programs/project_name
        copies source and encoder to temporary job directory, encodes the source
        uploads the resulting files to the file server, and deletes all temporary
        files.
        
        Sends status updates on encode to the message server every second'''
        
        homedir = os.path.expanduser('~')
        projectdir = os.path.join(homedir, 'cluster_programs', self._project_name)
        jobdir=os.path.join(homedir, 'cluster_programs', self._project_name, self._job_name)
        sourcedir=os.path.join('\\\\', self._server_ip,self._source_path)
        outputdir=os.path.join('\\\\', self._server_ip, self._destination_path)
        
        os.chdir(projectdir)
        try:
            os.mkdir(self._job_name)
        except OSError:
            logging.debug('Directory' + self._job_name +' exists, continuing using existing dir')
        
        shutil.copy(self._exe_name, self._job_name)
        os.chdir(jobdir)


        logging.debug('Connecting with message server')
        status_updates=MessageWriter(server=self._message_server, vhost=self._vhost, userid=self._userid, password=self._password, exchange='direct_transfer', exchange_durable=True, \
                              exchange_auto_delete=False, exchange_type='direct', routing_key=self._server_hostname, queue_durable=False, queue_auto_delete=True)
        logging.debug('Connection with message server established')
        
        logging.debug('Copying Source')                      
        status_updates.send_message(self._encode_message('Copying Source'))
        if os.path.exists('source'):
            shutil.rmtree('source')
        shutil.copytree(sourcedir, 'source')
        status_updates.send_message(self._encode_message('Finished Copying Source'))
        logging.debug('Finished Copying Source')
        
        logging.debug('Starting encode process '+self._exe_name)
        status_updates.send_message(self._encode_message('Starting Process '+self._exe_name))
        proc = subprocess.Popen(self._command, bufsize=1, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
        
        loglock=threading.Lock()
        logfile='encodinglog.txt'

        t = ProcessMonitor(proc, logfile, loglock)
        t.start()
        
        while proc.poll() is None:
            time.sleep(30)
            loglock.acquire()
            log=open(logfile, 'rU')
            current_progress=tail(log, 1)
            log.close()
            loglock.release()
            logging.debug(current_progress)
            status_updates.send_message(self._encode_message(current_progress))
            
        logging.debug('Finished Encoding')
        status_updates.send_message(self._encode_message('Finished Encoding'))
        
        logging.debug('Copying Output to Server')
        status_updates.send_message(self._encode_message('Copying Output to Server'))
        shutil.copy(self._output_file, outputdir)
        logging.debug('Finished Copying Output to Server')
        status_updates.send_message(self._encode_message('Finished Copying Output to Server'))
        
        os.chdir(homedir)
        logging.debug('Deleting temporary files and directories')
        shutil.rmtree(path=jobdir, ignore_errors=True)
        logging.debug('Closing connection with message server')
        status_updates.close()
Exemplo n.º 24
0
                    index = 0
                    for keyIn in element:
                        newkey = ".".join([key,keyIn])        
                        value1[".".join([key,keyIn])]=value[indexB][keyIn]
                        index += 1
                    for keyA in value1:
                        flattenDict(value1, result)   
        else:
            result[key]=value
    return result

header=''
jd=''
#from local
import tail
p, f = tail.tail("/var/ossec/logs/archives/archives.log")
#for s in sys.stdin:
while True:
    if p.poll(1):
        s=f.stdout.readline()
        start = s.find('{')
        if s[len(s) -2] == '}':
            d=s[start:]
            d=d.strip()
            jd=json.loads(d)
            jd=flattenDict(jd)
            header= s[0:start] 
            #print  ("%s %s") % (header,json.dumps(jd))
            result=merge(parse_header(header),jd)
            post("nix",result)
        else:
Exemplo n.º 25
0
from sys import argv
import cat
import echo
import head
import sort
import tail

if argv[1] == '-c':
    cat.cat(argv[2])
elif argv[1] == '-e':
    echo.echo(argv[2])
elif argv[1] == '-h':
    head.head(argv[2])
elif argv[1] == '-s':
    sort.sort(argv[2])
elif argv[1] == '-t':
    tail.tail(argv[2])
Exemplo n.º 26
0
Arquivo: empty.py Projeto: michK/SUAVE
def empty(vehicle):
    """ Computes weights estimates for human powered aircraft
    
    Assumptions:
       All of this is from AIAA 89-2048, units are in kg. These weight estimates
       are from the MIT Daedalus and are valid for very lightweight
       carbon fiber composite structures. This may need to be solved iteratively since
       gross weight is an input.
       
    Source: 
        MIT Daedalus
                       
    Inputs:
        wing - a data dictionary with the fields:
            Sw -       wing area                                                       [meters**2]
            bw -       wing span                                                       [meters]
            cw -       average wing chord                                              [meters]
            deltaw -   average rib spacing to average chord ratio                      [dimensionless]
            Nwr -      number of wing surface ribs (bw**2)/(deltaw*Sw)                 [dimensionless]
            t_cw -     wing airfoil thickness to chord ratio                           [dimensionless]
            Nwer -     number of wing end ribs (2*number of individual wing panels -2) [dimensionless]
            
        horizontal - a data dictionary with the fields:
            Sts -      tail surface area                                               [meters]
            bts -      tail surface span                                               [meters]
            cts -      average tail surface chord                                      [meters]
            deltawts - average rib spacing to average chord ratio                      [dimensionless]
            Ntsr -     number of tail surface ribs (bts^2)/(deltats*Sts)               [dimensionless]
            t_cts -    tail airfoil thickness to chord ratio                           [dimensionless]
            
        vertical - a data dictionary with the fields:
            Sts -      tail surface area                                               [meters]
            bts -      tail surface span                                               [meters]
            cts -      average tail surface chord                                      [meters]
            deltawts - average rib spacing to average chord ratio                      [dimensionless]
            Ntsr -     number of tail surface ribs (bts**2)/(deltats*Sts)              [dimensionless]
            t_cts -    tail airfoil thickness to chord ratio                           [dimensionless]
            
        aircraft - a data dictionary with the fields:    
            nult -     ultimate load factor                                            [dimensionless]
            GW -       aircraft gross weight                                           [kilogram]
            qm -       dynamic pressure at maneuvering speed                           [Pascals]
            Ltb -      tailboom length                                                 [meters]
    
    Outputs:
        Wws -      weight of wing spar                                                 [kilogram]
        Wtss -     weight of tail surface spar                                         [kilogram]
        Wwr -      weight of wing ribs                                                 [kilogram]
        Wtsr -     weight of tail surface ribs                                         [kilogram]
        Wwer -     weight of wing end ribs                                             [kilogram]
        WwLE -     weight of wing leading edge                                         [kilogram]
        WtsLE -    weight of tail surface leading edge                                 [kilogram]
        WwTE -     weight of wing trailing edge                                        [kilogram]
        Wwc -      weight of wing covering                                             [kilogram]
        Wtsc -     weight of tail surface covering                                     [kilogram]
        Wtb -      tailboom weight                                                     [kilogram]
                
    Properties Used:
        N/A
    """ 
    
    #Unpack
    
    nult   = vehicle.envelope.ultimate_load
    gw     = vehicle.mass_properties.max_takeoff
    qm     = vehicle.envelope.maximum_dynamic_pressure
    
    # Wing weight
    if not vehicle.wings.has_key('main_wing'):
        wt_wing = 0.0
        warnings.warn("There is no Wing Weight being added to the Configuration", stacklevel=1)
    else:
        Sw      = vehicle.wings['main_wing'].areas.reference
        bw      = vehicle.wings['main_wing'].spans.projected
        cw      = vehicle.wings['main_wing'].chords.mean_aerodynamic
        Nwr     = vehicle.wings['main_wing'].number_ribs
        t_cw    = vehicle.wings['main_wing'].thickness_to_chord
        Nwer    = vehicle.wings['main_wing'].number_end_ribs
        wt_wing = wing.wing(Sw,bw,cw,Nwr,t_cw,Nwer,nult,gw)
        vehicle.wings['main_wing'].mass_properties.mass = wt_wing
    
    # Horizontal Tail weight
    if not vehicle.wings.has_key('horizontal_stabilizer'):
        wt_ht = 0.0
        warnings.warn("There is no Horizontal Tail Weight being added to the Configuration", stacklevel=1)
    else:      
        S_h    = vehicle.wings['horizontal_stabilizer'].areas.reference
        b_h    = vehicle.wings['horizontal_stabilizer'].spans.projected
        chs    = vehicle.wings['horizontal_stabilizer'].chords.mean_aerodynamic
        Nhsr   = vehicle.wings['horizontal_stabilizer'].number_ribs
        t_ch   = vehicle.wings['horizontal_stabilizer'].thickness_to_chord
        wt_ht  = tail.tail(S_h,b_h,chs,Nhsr,t_ch,qm)
        vehicle.wings['horizontal_stabilizer'].mass_properties.mass = wt_ht
    
    # Vertical Tail weight
    if not vehicle.wings.has_key('vertical_stabilizer'):   
        wt_vt = 0.0
        warnings.warn("There is no Vertical Tail Weight being added to the Configuration", stacklevel=1)    
    else:    
        S_v    = vehicle.wings['vertical_stabilizer'].areas.reference
        b_v    = vehicle.wings['vertical_stabilizer'].spans.projected
        cvs    = vehicle.wings['vertical_stabilizer'].chords.mean_aerodynamic
        Nvsr   = vehicle.wings['vertical_stabilizer'].number_ribs
        t_cv   = vehicle.wings['vertical_stabilizer'].thickness_to_chord
        wt_vt   = tail.tail(S_v,b_v,cvs,Nvsr,t_cv,qm)
        vehicle.wings['vertical_stabilizer'].mass_properties.mass = wt_vt

    # Fuselage weight
    if not vehicle.fuselages.has_key('fuselage'):   
        wt_tb = 0.0
        warnings.warn("There is no Fuselage Weight being added to the Configuration", stacklevel=1)    
    else: 
        Ltb     = vehicle.Ltb  
        wt_tb   = fuselage.fuselage(S_h,qm,Ltb)
        vehicle.Fuselages['fuselage'].mass_properties.mass = wt_tb
    
    weight                 = Data()
    weight.wing            = wt_wing
    weight.fuselage        = wt_tb
    weight.horizontal_tail = wt_ht
    weight.vertical_tail   = wt_vt
    
    weight.empty = wt_ht + wt_tb + wt_vt + wt_wing
    
    return weight
Exemplo n.º 27
0
def test_tail_various_args(my_file):
    assert tail(my_file.resolve(), 1) == ["Become a PyBites ninja!"]
    assert tail(my_file.resolve(), 2) == [
        "Keep calm and code in Python!",
        "Become a PyBites ninja!",
    ]