def __init__(self, generator):
        SearchList.__init__(self, generator)

        self.table_dict = generator.skin_dict['HistoryReport']

        # Calculate the tables once every refresh_interval mins
        self.refresh_interval = int(self.table_dict.get('refresh_interval', 5))
        self.cache_time = 0

        self.search_list_extension = {}

        # Make bootstrap specific labels in config file available to
        if 'BootstrapLabels' in generator.skin_dict:
            self.search_list_extension[
                'BootstrapLabels'] = generator.skin_dict['BootstrapLabels']
        else:
            syslog.syslog(
                syslog.LOG_DEBUG, "%s: No bootstrap specific labels found" %
                os.path.basename(__file__))

        # Make observation labels available to templates
        if 'Labels' in generator.skin_dict:
            self.search_list_extension['Labels'] = generator.skin_dict[
                'Labels']
        else:
            syslog.syslog(
                syslog.LOG_DEBUG,
                "%s: No observation labels found" % os.path.basename(__file__))
示例#2
0
 def __init__(self, generator):
     SearchList.__init__(self, generator)
     self.cny_dict = {
         2014: (31, 1),
         2015: (19, 2),
         2016: (8, 2),
         2017: (28, 1),
         2018: (16, 2),
         2019: (5, 2),
         2020: (25, 1),
         2021: (12, 2),
         2022: (1, 2),
         2023: (22, 1),
         2024: (10, 2),
         2025: (29, 1),
         2026: (17, 2),
         2027: (6, 2),
         2028: (26, 1),
         2029: (13, 2),
         2030: (3, 2),
         2031: (23, 1),
         2032: (11, 2),
         2033: (31, 1),
         2034: (19, 2),
         2035: (8, 2),
         2036: (28, 1),
         2037: (15, 2),
         2038: (4, 2),
         2039: (24, 1),
         2040: (12, 2)
     }
示例#3
0
 def __init__(self, generator):
     SearchList.__init__(self, generator)
     self.cny_dict = {
         2014: (31, 1),
         2015: (19, 2),
         2016: (8, 2),
         2017: (28, 1),
         2018: (16, 2),
         2019: (5, 2),
         2020: (25, 1),
         2021: (12, 2),
         2022: (1, 2),
         2023: (22, 1),
         2024: (10, 2),
         2025: (29, 1),
         2026: (17, 2),
         2027: (6, 2),
         2028: (26, 1),
         2029: (13, 2),
         2030: (3, 2),
         2031: (23, 1),
         2032: (11, 2),
         2033: (31, 1),
         2034: (19, 2),
         2035: (8, 2),
         2036: (28, 1),
         2037: (15, 2),
         2038: (4, 2),
         2039: (24, 1),
         2040: (12, 2)
     }
示例#4
0
 def __init__(self, generator):
     SearchList.__init__(self, generator)
     self.perihelion = (
         1388815380,
         1420363620,
         1451783460,
         1483527360,
         1514949360,
         1546507980,
         1578217260,
         1609577220,
         1641258900,
         1672862700,
         1704240300,
         1735977420,
         1767458340,
         1798957320,
         1830688560,
         1862057280,
         1893677520,
         1925343780,
         1956710760,
         1988427180,
         2019967080,
         2051406300,
         2083146360,
         2114556240,
         2146121040,
         2177834400,
         2209189740,
     )
     self.aphelion = (
         1404429000,
         1436187180,
         1467647760,
         1499129700,
         1530893640,
         1562265180,
         1593874200,
         1625538660,
         1656902640,
         1688634060,
         1720158900,
         1751581080,
         1783350180,
         1814758980,
         1846304100,
         1878020700,
         1909383600,
         1941064140,
         1972653000,
         2004036600,
         2035802580,
         2067270060,
         2098750260,
         2130495180,
         2161871520,
         2193490500,
         2225143020,
     )
    def __init__(self, generator):                                     
        SearchList.__init__(self, generator)
        self.table_dict = generator.skin_dict['TableGenerator']

        # Calculate the tables once every refresh_interval mins
        self.refresh_interval = int(self.table_dict.get('refresh_interval', 5))
        self.cache_time = 0
        self.search_list_extension = None
示例#6
0
    def __init__(self, generator):

        SearchList.__init__(self, generator)
        self.metar_dict = generator.skin_dict['MetarReport']

        self.refresh_interval = int(self.metar_dict.get('refresh_interval', 5))
        self.cache_time = 0

        self.search_list_extension = {}
示例#7
0
 def __init__(self, generator):
     SearchList.__init__(self, generator)
     self.perihelion = (1388815380, 1420363620, 1451783460, 1483527360,
                        1514949360, 1546507980, 1578217260, 1609577220,
                        1641258900, 1672862700, 1704240300, 1735977420,
                        1767458340, 1798957320, 1830688560, 1862057280,
                        1893677520, 1925343780, 1956710760, 1988427180,
                        2019967080, 2051406300, 2083146360, 2114556240,
                        2146121040, 2177834400, 2209189740)
     self.aphelion = (1404429000, 1436187180, 1467647760, 1499129700,
                      1530893640, 1562265180, 1593874200, 1625538660,
                      1656902640, 1688634060, 1720158900, 1751581080,
                      1783350180, 1814758980, 1846304100, 1878020700,
                      1909383600, 1941064140, 1972653000, 2004036600,
                      2035802580, 2067270060, 2098750260, 2130495180,
                      2161871520, 2193490500, 2225143020)
示例#8
0
    def __init__(self, generator):
        
        SearchList.__init__(self, generator)
        
        self.table_dict = generator.skin_dict['CalduinoExtension']
        
        self.formatter = generator.formatter
        self.converter = generator.converter
        
        # Update this search list once every refresh_interval mins (according to refresh interval of the XML)
        self.refresh_interval = int(self.table_dict.get('refresh_interval', 5))
        self.cache_time = 0
        
        # Get the location where the XML files are located
        self.xml_source_dir = self.table_dict.get('XML_ROOT', XML_DEFAULT_SOURCE_DIR)
        
        self.search_list_extension = {} 
        
        # Initialize search list
        self.search_list_extension['upTimeCald'] = 0
        self.search_list_extension['opOKCald'] = 0
        self.search_list_extension['opNOKCald'] = 0
        self.search_list_extension['opOKPoll'] = 0
        self.search_list_extension['opNOKPoll'] = 0
        self.search_list_extension['opLastTimePoll'] = 0
        self.search_list_extension['opMeanTimePoll'] = 0
        
        # Make bootstrap specific labels in config file available to
        if 'BootstrapLabels' in generator.skin_dict:
            self.search_list_extension['BootstrapLabels'] = generator.skin_dict['BootstrapLabels']
        else:
            syslog.syslog(syslog.LOG_DEBUG, "%s: No bootstrap specific labels found" % os.path.basename(__file__))

        # Make observation labels available to templates
        if 'Labels' in generator.skin_dict:
            self.search_list_extension['Labels'] = generator.skin_dict['Labels']
        else:
            syslog.syslog(syslog.LOG_DEBUG, "%s: No observation labels found" % os.path.basename(__file__))          

        # Make observation units available to templates
        if 'Units' in generator.skin_dict:
            self.search_list_extension['Units'] = generator.skin_dict['Units']
        else:
            syslog.syslog(syslog.LOG_DEBUG, "%s: No units found" % os.path.basename(__file__)) 
示例#9
0
    def __init__(self, generator):
        SearchList.__init__(self, generator)

        self.table_dict = generator.skin_dict['HistoryReport']

        # Calculate the tables once every refresh_interval mins
        self.refresh_interval = int(self.table_dict.get('refresh_interval', 5))
        self.cache_time = 0

        self.search_list_extension = {}

        # Make bootstrap specific labels in config file available to
        if 'BootstrapLabels' in generator.skin_dict:
            self.search_list_extension['BootstrapLabels'] = generator.skin_dict['BootstrapLabels']
        else:
            syslog.syslog(syslog.LOG_DEBUG, "%s: No bootstrap specific labels found" % os.path.basename(__file__))

        # Make observation labels available to templates
        if 'Labels' in generator.skin_dict:
            self.search_list_extension['Labels'] = generator.skin_dict['Labels']
        else:
            syslog.syslog(syslog.LOG_DEBUG, "%s: No observation labels found" % os.path.basename(__file__))
示例#10
0
 def __init__(self, generator):
     SearchList.__init__(self, generator)
     self.table_dict = generator.skin_dict['IndexColors']
示例#11
0
    def __init__(self, generator):
        SearchList.__init__(self, generator)
        self.periarg = array('f', [
            2, 0, 0, 4, 0, 0, 6, 0, 0, 8, 0, 0, 2, -1, 0, 0, 1, 0, 10, 0, 0, 4,
            -1, 0, 6, -1, 0, 12, 0, 0, 1, 0, 0, 8, -1, 0, 14, 0, 0, 0, 0, 2, 3,
            0, 0, 10, -1, 0, 16, 0, 0, 12, -1, 0, 5, 0, 0, 2, 0, 2, 18, 0, 0,
            14, -1, 0, 7, 0, 0, 2, 1, 0, 20, 0, 0, 1, 1, 0, 16, -1, 0, 4, 1, 0,
            9, 0, 0, 4, 0, 2, 2, -2, 0, 4, -2, 0, 6, -2, 0, 22, 0, 0, 18, -1,
            0, 6, 1, 0, 11, 0, 0, 8, 1, 0, 4, 0, -2, 6, 0, 2, 3, 1, 0, 5, 1, 0,
            13, 0, 0, 20, -1, 0, 3, 2, 0, 4, -2, 2, 1, 2, 0, 22, -1, 0, 0, 0,
            4, 6, 0, -2, 2, 1, -2, 0, 2, 0, 0, -1, 2, 2, 0, 4, 0, -2, 2, 2, 2,
            -2, 24, 0, 0, 4, 0, -4, 2, 2, 0, 1, -1, 0
        ])

        self.pericoeff = array('f', [
            -1.6769, 0.4589, -0.1856, 0.0883, -0.0773, 0.0502, -0.0460, 0.0422,
            -0.0256, 0.0253, 0.0237, 0.0162, -0.0145, 0.0129, -0.0112, -0.0104,
            0.0086, 0.0069, 0.0066, -0.0053, -0.0052, -0.0046, -0.0041, 0.0040,
            0.0032, -0.0032, 0.0031, -0.0029, 0.0027, 0.0027, -0.0027, 0.0024,
            -0.0021, -0.0021, -0.0021, 0.0019, -0.0018, -0.0014, -0.0014,
            -0.0014, 0.0014, -0.0014, 0.0013, 0.0013, 0.0011, -0.0011, -0.0010,
            -0.0009, -0.0008, 0.0008, 0.0008, 0.0007, 0.0007, 0.0007, -0.0006,
            -0.0006, 0.0006, 0.0005, 0.0005, -0.0004, 0
        ])

        self.peritft = array('f', [4, 5, 7, -1])

        self.peritfc = array('f', [0.00019, -0.00013, -0.00011])

        self.apoarg = array('f', [
            2, 0, 0, 4, 0, 0, 0, 1, 0, 2, -1, 0, 0, 0, 2, 1, 0, 0, 6, 0, 0, 4,
            -1, 0, 2, 0, 2, 1, 1, 0, 8, 0, 0, 6, -1, 0, 2, 0, -2, 2, -2, 0, 3,
            0, 0, 4, 0, 2, 8, -1, 0, 4, -2, 0, 10, 0, 0, 3, 1, 0, 0, 2, 0, 2,
            1, 0, 2, 2, 0, 6, 0, 2, 6, -2, 0, 10, -1, 0, 5, 0, 0, 4, 0, -2, 0,
            1, 2, 12, 0, 0, 2, -1, 2, 1, -1, 0
        ])

        self.apocoeff = array('f', [
            0.4392, 0.0684, 0.0456, 0.0426, 0.0212, -0.0189, 0.0144, 0.0113,
            0.0047, 0.0036, 0.0035, 0.0034, -0.0034, 0.0022, -0.0017, 0.0013,
            0.0011, 0.0010, 0.0009, 0.0007, 0.0006, 0.0005, 0.0005, 0.0004,
            0.0004, 0.0004, -0.0004, -0.0004, 0.0003, 0.0003, 0.0003, -0.0003,
            0
        ])

        self.apotft = array('f', [2, 3, -1])

        self.apotfc = array('f', [-0.00011, -0.00011])

        self.periparg = array('f', [
            0, 0, 0, 2, 0, 0, 4, 0, 0, 2, -1, 0, 6, 0, 0, 1, 0, 0, 8, 0, 0, 0,
            1, 0, 0, 0, 2, 4, -1, 0, 2, 0, -2, 10, 0, 0, 6, -1, 0, 3, 0, 0, 2,
            1, 0, 1, 1, 0, 12, 0, 0, 8, -1, 0, 2, 0, 2, 2, -2, 0, 5, 0, 0, 14,
            0, 0, 10, -1, 0, 4, 1, 0, 12, -1, 0, 4, -2, 0, 7, 0, 0, 4, 0, 2,
            16, 0, 0, 3, 1, 0, 1, -1, 0, 6, 1, 0, 0, 2, 0, 14, -1, 0, 2, 2, 0,
            6, -2, 0, 2, -1, -2, 9, 0, 0, 18, 0, 0, 6, 0, 2, 0, -1, 2, 16, -1,
            0, 4, 0, -2, 8, 1, 0, 11, 0, 0, 5, 1, 0, 20, 0, 0
        ])

        self.peripcoeff = array('f', [
            3629.215, 63.224, -6.990, 2.834, 1.927, -1.263, -0.702, 0.696,
            -0.690, -0.629, -0.392, 0.297, 0.260, 0.201, -0.161, 0.157, -0.138,
            -0.127, 0.104, 0.104, -0.079, 0.068, 0.067, 0.054, -0.038, -0.038,
            0.037, -0.037, -0.035, -0.030, 0.029, -0.025, 0.023, 0.023, -0.023,
            0.022, -0.021, -0.020, 0.019, 0.017, 0.014, -0.014, 0.013, 0.012,
            0.011, 0.010, -0.010, 0
        ])

        self.periptft = array('f', [3, 7, 9, -1])

        self.periptfc = array('f', [-0.0071, -0.0017, 0.0016])

        self.apoparg = array('f', [
            0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0, 2, 0, 1, 0, 4, 0, 0, 2, -1, 0, 1,
            1, 0, 4, -1, 0, 6, 0, 0, 2, 1, 0, 2, 0, 2, 2, 0, -2, 2, -2, 0, 2,
            2, 0, 0, 2, 0, 6, -1, 0, 8, 0, 0
        ])

        self.apopcoeff = array('f', [
            3245.251, -9.147, -0.841, 0.697, -0.656, 0.355, 0.159, 0.127,
            0.065, 0.052, 0.043, 0.031, -0.023, 0.022, 0.019, -0.016, 0.014,
            0.010, 0
        ])

        self.apoptft = array('f', [4, -1])

        self.apoptfc = array('f', [0.0016, -1])
        self.apsis_type_lookup = {'p': 'perigee', 'a': 'apogee'}
示例#12
0
 def __init__(self, generator):
     SearchList.__init__(self, generator)
     self.solar_eclipses = ((1414100739,
                             'A'), (1414100739,
                                    'P'), (1426844807,
                                           'T'), (1442127319,
                                                  'P'), (1457488699, 'T'),
                            (1472720882,
                             'A'), (1488120873,
                                    'A'), (1503340000,
                                           'T'), (1518727953,
                                                  'P'), (1531450936, 'P'),
                            (1533980848,
                             'P'), (1546738958,
                                    'P'), (1562095447,
                                           'T'), (1577337533,
                                                  'A'), (1592721675, 'A'),
                            (1607962479,
                             'T'), (1623321787,
                                    'A'), (1638603278,
                                           'T'), (1651351356,
                                                  'P'), (1666695680, 'P'),
                            (1681964276,
                             'H'), (1697306441,
                                    'A'), (1712600309,
                                           'T'), (1727894773,
                                                  'A'), (1743245316, 'P'),
                            (1758483784,
                             'P'), (1771330386,
                                    'A'), (1786556826,
                                           'T'), (1801929648,
                                                  'A'), (1817201270, 'T'),
                            (1832512139,
                             'A'), (1847847400,
                                    'T'), (1863105228,
                                           'P'), (1875931573,
                                                  'P'), (1878478639, 'P'),
                            (1891177438,
                             'P'), (1906525753,
                                    'A'), (1921819897,
                                           'T'), (1937114164,
                                                  'A'), (1952456851,
                                                         'H'), (1967722002,
                                                                'A'),
                            (1983072853,
                             'P'), (1995818556,
                                    'T'), (2011096471,
                                           'P'), (2026462725,
                                                  'T'), (2041690768,
                                                         'A'), (2057094354,
                                                                'A'),
                            (2072311006,
                             'T'), (2087700409,
                                    'P'), (2100421926,
                                           'P'), (2102952345,
                                                  'P'), (2115712135,
                                                         'P'), (2131065636,
                                                                'T'),
                            (2146312031,
                             'A'), (2161690375,
                                    'A'), (2176938010,
                                           'T'), (2192289174,
                                                  'A'), (2207579026,
                                                         'T'), (2220320582,
                                                                'P'))
     self.solar_eclipse_type_lookup = {
         'A': 'Annular',
         'H': 'Hybrid',
         'P': 'Partial',
         'T': 'Total'
     }
     self.lunar_eclipses = ((1308168823,
                             'T'), (1323527576,
                                    'T'), (1338807860,
                                           'P'), (1354113247,
                                                  'Pe'), (1366920518, 'P'),
                            (1369455066, 'Pe'), (1382140285,
                                                 'Pe'), (1397548008, 'T'),
                            (1412765744,
                             'T'), (1428148884,
                                    'T'), (1443408497,
                                           'T'), (1458733701,
                                                  'Pe'), (1474052127, 'Pe'),
                            (1486773903, 'Pe'), (1502130098,
                                                 'P'), (1517405460, 'T'),
                            (1532722974,
                             'T'), (1548047607,
                                    'T'), (1563312715,
                                           'P'), (1578683471,
                                                  'Pe'), (1591385174, 'Pe'),
                            (1593923472,
                             'Pe'), (1606729441,
                                     'Pe'), (1622027993,
                                             'T'), (1637312646,
                                                    'P'), (1652674362, 'T'),
                            (1667905222,
                             'T'), (1683307445,
                                    'Pe'), (1698524118,
                                            'P'), (1711350839,
                                                   'Pe'), (1726627525, 'P'),
                            (1741935596,
                             'T'), (1757268778,
                                    'T'), (1772537692,
                                           'T'), (1787890444,
                                                  'P'), (1803165246,
                                                         'Pe'), (1815926649,
                                                                 'Pe'),
                            (1818486899,
                             'Pe'), (1831263253,
                                     'P'), (1846520457,
                                            'P'), (1861894395,
                                                   'T'), (1877138602, 'T'),
                            (1892500992,
                             'T'), (1907778874,
                                    'P'), (1923085731,
                                           'Pe'), (1935892322,
                                                   'Pe'), (1938426317,
                                                           'Pe'),
                            (1951112805,
                             'Pe'), (1966518891,
                                     'T'), (1981739020,
                                            'T'), (1997118831,
                                                   'T'), (2012381783,
                                                          'T'), (2027704019,
                                                                 'Pe'),
                            (2043024457,
                             'P'), (2055747972,
                                    'Pe'), (2071098735,
                                            'P'), (2086380786,
                                                   'T'), (2101690352, 'T'),
                            (2117023298,
                             'T'), (2132280593,
                                    'P'), (2147658592,
                                           'Pe'), (2160355502,
                                                   'Pe'), (2162892956,
                                                           'Pe'),
                            (2175702300,
                             'Pe'), (2190999265,
                                     'P'), (2206284988,
                                            'P'), (2221645582,
                                                   'T'), (2236878281, 'T'))
     self.lunar_eclipse_type_lookup = {
         'P': 'Partial',
         'Pe': 'Penumbral',
         'T': 'Total'
     }
示例#13
0
    def __init__(self, generator):
        SearchList.__init__(self, generator)
        self.periarg = array('f', [
            2, 0, 0, 4, 0, 0, 6, 0, 0, 8, 0, 0, 2, -1, 0, 0, 1, 0, 10, 0, 0, 4,
            -1, 0, 6, -1, 0, 12, 0, 0, 1, 0, 0, 8, -1, 0, 14, 0, 0, 0, 0, 2, 3,
            0, 0, 10, -1, 0, 16, 0, 0, 12, -1, 0, 5, 0, 0, 2, 0, 2, 18, 0, 0,
            14, -1, 0, 7, 0, 0, 2, 1, 0, 20, 0, 0, 1, 1, 0, 16, -1, 0, 4, 1, 0,
            9, 0, 0, 4, 0, 2, 2, -2, 0, 4, -2, 0, 6, -2, 0, 22, 0, 0, 18, -1,
            0, 6, 1, 0, 11, 0, 0, 8, 1, 0, 4, 0, -2, 6, 0, 2, 3, 1, 0, 5, 1, 0,
            13, 0, 0, 20, -1, 0, 3, 2, 0, 4, -2, 2, 1, 2, 0, 22, -1, 0, 0, 0,
            4, 6, 0, -2, 2, 1, -2, 0, 2, 0, 0, -1, 2, 2, 0, 4, 0, -2, 2, 2, 2,
            -2, 24, 0, 0, 4, 0, -4, 2, 2, 0, 1, -1, 0
        ])

        self.pericoeff = array('f', [
            -1.6769, 0.4589, -0.1856, 0.0883, -0.0773, 0.0502, -0.0460, 0.0422,
            -0.0256, 0.0253, 0.0237, 0.0162, -0.0145, 0.0129, -0.0112, -0.0104,
            0.0086, 0.0069, 0.0066, -0.0053, -0.0052, -0.0046, -0.0041, 0.0040,
            0.0032, -0.0032, 0.0031, -0.0029, 0.0027, 0.0027, -0.0027, 0.0024,
            -0.0021, -0.0021, -0.0021, 0.0019, -0.0018, -0.0014, -0.0014,
            -0.0014, 0.0014, -0.0014, 0.0013, 0.0013, 0.0011, -0.0011, -0.0010,
            -0.0009, -0.0008, 0.0008, 0.0008, 0.0007, 0.0007, 0.0007, -0.0006,
            -0.0006, 0.0006, 0.0005, 0.0005, -0.0004, 0
        ])

        self.peritft = array('f', [4, 5, 7, -1])

        self.peritfc = array('f', [0.00019, -0.00013, -0.00011])

        self.apoarg = array('f', [
            2, 0, 0, 4, 0, 0, 0, 1, 0, 2, -1, 0, 0, 0, 2, 1, 0, 0, 6, 0, 0, 4,
            -1, 0, 2, 0, 2, 1, 1, 0, 8, 0, 0, 6, -1, 0, 2, 0, -2, 2, -2, 0, 3,
            0, 0, 4, 0, 2, 8, -1, 0, 4, -2, 0, 10, 0, 0, 3, 1, 0, 0, 2, 0, 2,
            1, 0, 2, 2, 0, 6, 0, 2, 6, -2, 0, 10, -1, 0, 5, 0, 0, 4, 0, -2, 0,
            1, 2, 12, 0, 0, 2, -1, 2, 1, -1, 0
        ])

        self.apocoeff = array('f', [
            0.4392, 0.0684, 0.0456, 0.0426, 0.0212, -0.0189, 0.0144, 0.0113,
            0.0047, 0.0036, 0.0035, 0.0034, -0.0034, 0.0022, -0.0017, 0.0013,
            0.0011, 0.0010, 0.0009, 0.0007, 0.0006, 0.0005, 0.0005, 0.0004,
            0.0004, 0.0004, -0.0004, -0.0004, 0.0003, 0.0003, 0.0003, -0.0003,
            0
        ])

        self.apotft = array('f', [2, 3, -1])

        self.apotfc = array('f', [-0.00011, -0.00011])

        self.periparg = array('f', [
            0, 0, 0, 2, 0, 0, 4, 0, 0, 2, -1, 0, 6, 0, 0, 1, 0, 0, 8, 0, 0, 0,
            1, 0, 0, 0, 2, 4, -1, 0, 2, 0, -2, 10, 0, 0, 6, -1, 0, 3, 0, 0, 2,
            1, 0, 1, 1, 0, 12, 0, 0, 8, -1, 0, 2, 0, 2, 2, -2, 0, 5, 0, 0, 14,
            0, 0, 10, -1, 0, 4, 1, 0, 12, -1, 0, 4, -2, 0, 7, 0, 0, 4, 0, 2,
            16, 0, 0, 3, 1, 0, 1, -1, 0, 6, 1, 0, 0, 2, 0, 14, -1, 0, 2, 2, 0,
            6, -2, 0, 2, -1, -2, 9, 0, 0, 18, 0, 0, 6, 0, 2, 0, -1, 2, 16, -1,
            0, 4, 0, -2, 8, 1, 0, 11, 0, 0, 5, 1, 0, 20, 0, 0
        ])

        self.peripcoeff = array('f', [
            3629.215, 63.224, -6.990, 2.834, 1.927, -1.263, -0.702, 0.696,
            -0.690, -0.629, -0.392, 0.297, 0.260, 0.201, -0.161, 0.157, -0.138,
            -0.127, 0.104, 0.104, -0.079, 0.068, 0.067, 0.054, -0.038, -0.038,
            0.037, -0.037, -0.035, -0.030, 0.029, -0.025, 0.023, 0.023, -0.023,
            0.022, -0.021, -0.020, 0.019, 0.017, 0.014, -0.014, 0.013, 0.012,
            0.011, 0.010, -0.010, 0
        ])

        self.periptft = array('f', [3, 7, 9, -1])

        self.periptfc = array('f', [-0.0071, -0.0017, 0.0016])

        self.apoparg = array('f', [
            0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0, 2, 0, 1, 0, 4, 0, 0, 2, -1, 0, 1,
            1, 0, 4, -1, 0, 6, 0, 0, 2, 1, 0, 2, 0, 2, 2, 0, -2, 2, -2, 0, 2,
            2, 0, 0, 2, 0, 6, -1, 0, 8, 0, 0
        ])

        self.apopcoeff = array('f', [
            3245.251, -9.147, -0.841, 0.697, -0.656, 0.355, 0.159, 0.127,
            0.065, 0.052, 0.043, 0.031, -0.023, 0.022, 0.019, -0.016, 0.014,
            0.010, 0
        ])

        self.apoptft = array('f', [4, -1])

        self.apoptfc = array('f', [0.0016, -1])
        self.apsis_type_lookup = {'p': 'perigee', 'a': 'apogee'}
示例#14
0
 def __init__(self, generator):
     SearchList.__init__(self, generator)
     self.solar_eclipses = ((1414100739, 'A'), (1414100739,
                                                'P'), (1426844807, 'T'),
                            (1442127319, 'P'), (1457488699,
                                                'T'), (1472720882, 'A'),
                            (1488120873, 'A'), (1503340000,
                                                'T'), (1518727953, 'P'),
                            (1531450936, 'P'), (1533980848,
                                                'P'), (1546738958, 'P'),
                            (1562095447, 'T'), (1577337533,
                                                'A'), (1592721675, 'A'),
                            (1607962479, 'T'), (1623321787,
                                                'A'), (1638603278, 'T'),
                            (1651351356, 'P'), (1666695680,
                                                'P'), (1681964276, 'H'),
                            (1697306441, 'A'), (1712600309,
                                                'T'), (1727894773, 'A'),
                            (1743245316, 'P'), (1758483784,
                                                'P'), (1771330386, 'A'),
                            (1786556826, 'T'), (1801929648,
                                                'A'), (1817201270, 'T'),
                            (1832512139, 'A'), (1847847400,
                                                'T'), (1863105228, 'P'),
                            (1875931573,
                             'P'), (1878478639,
                                    'P'), (1891177438,
                                           'P'), (1906525753,
                                                  'A'), (1921819897, 'T'),
                            (1937114164,
                             'A'), (1952456851,
                                    'H'), (1967722002,
                                           'A'), (1983072853,
                                                  'P'), (1995818556, 'T'),
                            (2011096471,
                             'P'), (2026462725,
                                    'T'), (2041690768,
                                           'A'), (2057094354,
                                                  'A'), (2072311006, 'T'),
                            (2087700409,
                             'P'), (2100421926,
                                    'P'), (2102952345,
                                           'P'), (2115712135,
                                                  'P'), (2131065636, 'T'),
                            (2146312031,
                             'A'), (2161690375,
                                    'A'), (2176938010,
                                           'T'), (2192289174,
                                                  'A'), (2207579026,
                                                         'T'), (2220320582,
                                                                'P'))
     self.solar_eclipse_type_lookup = {
         'A': 'Annular',
         'H': 'Hybrid',
         'P': 'Partial',
         'T': 'Total'
     }
     self.lunar_eclipses = (
         (1308168823, 'T'), (1323527576, 'T'), (1338807860, 'P'),
         (1354113247, 'Pe'), (1366920518, 'P'), (1369455066, 'Pe'),
         (1382140285, 'Pe'), (1397548008, 'T'), (1412765744,
                                                 'T'), (1428148884, 'T'),
         (1443408497, 'T'),
         (1458733701, 'Pe'), (1474052127, 'Pe'), (1486773903,
                                                  'Pe'), (1502130098, 'P'),
         (1517405460,
          'T'), (1532722974,
                 'T'), (1548047607,
                        'T'), (1563312715,
                               'P'), (1578683471,
                                      'Pe'), (1591385174,
                                              'Pe'), (1593923472, 'Pe'),
         (1606729441, 'Pe'), (1622027993, 'T'), (1637312646,
                                                 'P'), (1652674362, 'T'),
         (1667905222,
          'T'), (1683307445,
                 'Pe'), (1698524118,
                         'P'), (1711350839,
                                'Pe'), (1726627525,
                                        'P'), (1741935596,
                                               'T'), (1757268778, 'T'),
         (1772537692,
          'T'), (1787890444,
                 'P'), (1803165246,
                        'Pe'), (1815926649,
                                'Pe'), (1818486899,
                                        'Pe'), (1831263253,
                                                'P'), (1846520457, 'P'),
         (1861894395,
          'T'), (1877138602,
                 'T'), (1892500992,
                        'T'), (1907778874,
                               'P'), (1923085731,
                                      'Pe'), (1935892322,
                                              'Pe'), (1938426317, 'Pe'),
         (1951112805, 'Pe'), (1966518891, 'T'), (1981739020,
                                                 'T'), (1997118831,
                                                        'T'), (2012381783,
                                                               'T'),
         (2027704019, 'Pe'), (2043024457, 'P'), (2055747972,
                                                 'Pe'), (2071098735, 'P'),
         (2086380786, 'T'), (2101690352, 'T'), (2117023298,
                                                'T'), (2132280593, 'P'),
         (2147658592, 'Pe'), (2160355502, 'Pe'), (2162892956,
                                                  'Pe'), (2175702300, 'Pe'),
         (2190999265, 'P'), (2206284988, 'P'), (2221645582,
                                                'T'), (2236878281, 'T'))
     self.lunar_eclipse_type_lookup = {
         'P': 'Partial',
         'Pe': 'Penumbral',
         'T': 'Total'
     }
    def __init__(self, generator):
        SearchList.__init__(self, generator)
        self.aus = { "feelslike" : self.feelslikeFunc }
        #put these in the skin_dict so we can change them easily!
        self.aus['icons'] = { 
                              '1' : 'http://www.bom.gov.au/images/symbols/large/sunny.png', 
                              '2' : 'http://www.bom.gov.au/images/symbols/large/clear.png', 
                              '3' : 'http://www.bom.gov.au/images/symbols/large/partly-cloudy.png',
                              '4' : 'http://www.bom.gov.au/images/symbols/large/cloudy.png',
                              '5' : '',
                              '6' : 'http://www.bom.gov.au/images/symbols/large/haze.png',
                              '7' : '',
                              '8' : 'http://www.bom.gov.au/images/symbols/large/light-rain.png',
                              '9' : 'http://www.bom.gov.au/images/symbols/large/wind.png',
                              '10' : 'http://www.bom.gov.au/images/symbols/large/fog.png',
                              '11' : 'http://www.bom.gov.au/images/symbols/large/showers.png',
                              '12' : 'http://www.bom.gov.au/images/symbols/large/rain.png',
                              '13' : 'http://www.bom.gov.au/images/symbols/large/dust.png',
                              '14' : 'http://www.bom.gov.au/images/symbols/large/frost.png',
                              '15' : 'http://www.bom.gov.au/images/symbols/large/snow.png',
                              '16' : 'http://www.bom.gov.au/images/symbols/large/storm.png',
                              '17' : 'http://www.bom.gov.au/images/symbols/large/light-showers.png',
                              '18' : 'http://www.bom.gov.au/images/symbols/large/heavy-showers.png' 
                            }
                            
        self.aus['iconsSml'] = { 
                              '1' : 'http://www.bom.gov.au/images/symbols/small/sunny.png', 
                              '2' : 'http://www.bom.gov.au/images/symbols/small/clear.png', 
                              '3' : 'http://www.bom.gov.au/images/symbols/small/partly-cloudy.png',
                              '4' : 'http://www.bom.gov.au/images/symbols/small/cloudy.png',
                              '5' : '',
                              '6' : 'http://www.bom.gov.au/images/symbols/small/haze.png',
                              '7' : '',
                              '8' : 'http://www.bom.gov.au/images/symbols/small/light-rain.png',
                              '9' : 'http://www.bom.gov.au/images/symbols/small/wind.png',
                              '10' : 'http://www.bom.gov.au/images/symbols/small/fog.png',
                              '11' : 'http://www.bom.gov.au/images/symbols/small/showers.png',
                              '12' : 'http://www.bom.gov.au/images/symbols/small/rain.png',
                              '13' : 'http://www.bom.gov.au/images/symbols/small/dust.png',
                              '14' : 'http://www.bom.gov.au/images/symbols/small/frost.png',
                              '15' : 'http://www.bom.gov.au/images/symbols/small/snow.png',
                              '16' : 'http://www.bom.gov.au/images/symbols/small/storm.png',
                              '17' : 'http://www.bom.gov.au/images/symbols/small/light-showers.png',
                              '18' : 'http://www.bom.gov.au/images/symbols/small/heavy-showers.png'  
                            }                            
                            
        self.aus['rainImgs'] = { 
                              '0%' : 'http://www.bom.gov.au/images/ui/weather/rain_0.gif',
                              '5%' : 'http://www.bom.gov.au/images/ui/weather/rain_5.gif',
                              '10%' : 'http://www.bom.gov.au/images/ui/weather/rain_10.gif',
                              '20%' : 'http://www.bom.gov.au/images/ui/weather/rain_20.gif',
                              '30%' : 'http://www.bom.gov.au/images/ui/weather/rain_30.gif',
                              '40%' : 'http://www.bom.gov.au/images/ui/weather/rain_40.gif',
                              '50%' : 'http://www.bom.gov.au/images/ui/weather/rain_50.gif',
                              '60%' : 'http://www.bom.gov.au/images/ui/weather/rain_60.gif',
                              '70%' : 'http://www.bom.gov.au/images/ui/weather/rain_70.gif',
                              '80%' : 'http://www.bom.gov.au/images/ui/weather/rain_80.gif',
                              '90%' : 'http://www.bom.gov.au/images/ui/weather/rain_90.gif',
                              '95%' : 'http://www.bom.gov.au/images/ui/weather/rain_95.gif',
                              '100%' : 'http://www.bom.gov.au/images/ui/weather/rain_100.gif'
                            }     
        
        try:
            self.cache_root = self.generator.skin_dict['AusSearch']['cache_root']
        except KeyError:
            self.cache_root = '/var/lib/weewx/aussearch'
        
        try:
            self.staleness_time = float(self.generator.skin_dict['AusSearch']['staleness_time'])
        except KeyError:
            self.staleness_time = 15 * 60 #15 minutes
        
        if not os.path.exists(self.cache_root):
            os.makedirs(self.cache_root)
        
        try:
            xml_files = self.generator.skin_dict['AusSearch']['xml_files']
        except:
            xml_files = None
        
        for xml_file in xml_files:
            self.aus[xml_file] = XmlFileHelper(self.generator.skin_dict['AusSearch']['xml_files'][xml_file],
                                                 self,
                                                 generator.formatter,
                                                 generator.converter)

        try:
            localization = self.generator.skin_dict['AusSearch']['local']
        except:
            localization = None

        for localization_object in localization:
            try:
                self.aus[localization_object] = self.aus[self.generator.skin_dict['AusSearch']['local'][localization_object]]
            except KeyError:
                syslog.syslog(syslog.LOG_ERR, "aussearch: localization error for %s" % (localization_object))

        try:
            index_locality = self.generator.skin_dict['AusSearch']['localities']['index_locality']
        except:
            index_locality = 'Sydney'

        self.aus['index_locality'] = index_locality
示例#16
0
    def __init__(self, generator):
        SearchList.__init__(self, generator)

        self.table_dict = generator.skin_dict['HistoryReport']

        # Calculate the tables once every refresh_interval mins
        self.refresh_interval = int(self.table_dict.get('refresh_interval', 5))
        self.cache_time = 0

        self.search_list_extension = {}

        # Make bootstrap specific labels in config file available to templates
        if 'BootstrapLabels' in generator.skin_dict:
            self.search_list_extension[
                'BootstrapLabels'] = generator.skin_dict['BootstrapLabels']
        else:
            log.debug("%s: No bootstrap specific labels found" %
                      os.path.basename(__file__))

        # Make observation labels available to templates
        if 'Labels' in generator.skin_dict:
            self.search_list_extension['Labels'] = generator.skin_dict[
                'Labels']
        else:
            log.debug("%s: No observation labels found" %
                      os.path.basename(__file__))

        # Make LiveGauges specific labels in config file available to templates
        if 'LiveGauges' in generator.skin_dict:
            self.search_list_extension['LiveGauges'] = generator.skin_dict[
                'LiveGauges']
        else:
            log.debug("%s: No LiveGauges specific labels found" %
                      os.path.basename(__file__))

        # Make LiveCharts specific labels in config file available to templates
        if 'LiveCharts' in generator.skin_dict:
            self.search_list_extension['LiveCharts'] = generator.skin_dict[
                'LiveCharts']
        else:
            log.debug("%s: No LiveCharts specific labels found" %
                      os.path.basename(__file__))

        # Make ImageGenerator specific labels in config file available to templates
        image_dict = {}
        image_config_path = os.path.join(
            generator.config_dict['WEEWX_ROOT'],
            generator.config_dict['StdReport']['SKIN_ROOT'], 'Images',
            "skin.conf")
        try:
            image_dict = ConfigObj(image_config_path)
        except:
            log.info(
                "%s: Could not import image dictionary %s" %
                os.path.basename(__file__), image_config_path)
        if 'ImageGenerator' in image_dict:
            self.search_list_extension['ImageGenerator'] = image_dict[
                'ImageGenerator']
        else:
            log.debug("%s: No ImageGenerator specific labels found" %
                      os.path.basename(__file__))
示例#17
0
 def __init__(self, generator):
     SearchList.__init__(self, generator)
示例#18
0
    def __init__(self, generator):
        SearchList.__init__(self, generator)

        """
        This is a minimal SLE - all we want is to make the php configuration
        easier by transferring the database values as used by weewx, plus a few
        other variables.
        It has since expanded to allow the transfer of the sqlite database
        by using rsync, providing the [Remote] section of the config is
        populated

        In wxobs/skin.conf:

        send_inc: An option to stop sending the include file/s. These contain
        the database configuration values, timezone and oprional debugging
        stanzas for the php script to operate. Needless to say you need to
        send them at least once.
        If you can't think of a reason why you'd need this then you don't need
        to implement it.
        I run a mysql database locally and export an sqlite to the remote. This
        allows me to do that without too much trouble (remembering to set up
        the symlinks is the biggest issue)

        include_path: the directory where the php include file will be stored
        this holds the database configuration as sourced from weewx.conf
        If you store them locally you can change that path using this option.
        If you send the files to another server you can change this path using
        dest_directory (which will affect the database also.)

        disp_interval: is the time between displayed records; 1800 is a
        half-hour and is the default

        display_type: 'single' (default) or 'average'
        Whether to return the timestamped entry for the value displayed in the
        periodic Stats table (single), or average it over all the database
        entries between it and the previous one that was displayed. (average)

        app_Temp: This is a recent addition to weewx and is not enabled by
        default. The calculation is performed but there is no field in the
        stock database. This variable allows for the substitution with another
        value.
        The default is to use windchill.
        Keep it to the group_degrees (because the label is hard coded in.)

        timezone: If the date or time is not being displayed correctly
        we'll assume it's a php issue and pass a timezone string to the script.
        This can be done by adding your time zone as the following example
        indicates.  Replace the string with your zone description
        timezone = Melbourne/Australia

        self.php_error: enable php error messages in index.php.
        This maybe useful at the start of configuration, it shouldn't be
        needed after everything is running smoothly
        default is False. set to True to enable this to be sent via the
        include file.

        [[Remote]]
        This is used when you want to transfer the include file and the
        database to a remote machine where the web files have been sent
        seperately with the weewx.conf [FTP] or [RSYNC] section.
        dest_directory: is the switch that turns this o. It transfers BOTH the
        include and database files to the same directory as the tuple specifies
        If using multiple databases and include files make sure they are unique
        ie:-  if you are transferring from multiple machine.
        It will fetch the rsync user and server from the wxobs/skin.conf file
        and use those values or if they are missing then it will use the values
        from the [RSYNC] section of weewx.conf which is possibly configured
        already.
        rsync_user (user) = user_name for rsync command
        rsync_server (server)= ip address of the remote machine
        send_include = True #This is the default, set to False if you don't
        want to send the include file repeatedly to the server. Use with
        caution (ie: remember this setting when things stop working, it might
        be the cure)
        rsync_options: Not documented in the skin.conf Default is '-ac'. Use
        with caution and no spaces allowed.

        [[RainTiming]]
        shift_rain: For rain accounting times other than midnight to midnight
        set this to True
        If no other options are given the accounting time will be the
        australian rain day which starts at 9 a.m.
        default is false - start at midnight 00:00:00 through to the next day.

        rain_start: used to shift time (in seconds) to something other than
        9a.m. The default is 32400

        rain_label: the o'clock label for the rain_start above.
        default is 9

        show_warning: An information message will appear on the report page
        (index.php) if the database is in US units (imperial) or units are
        detected that don't match the native units required for the delta-T
        calcs.
        An information div is included in the report page when this occurs.
        This is a switch (boolean) to turn it off.

        wxobs_debug: Allow index.php to include debugging info if set to...
        1 and above is low level, variables, some logic.
        2 is for wxobs remote cmds etc.
        3 only for delta-T final values (low level - if enabled)
        4 only for delta-T unit conversion calcs (verbose) - if enabled
        5 only for ordinalCompass conversion calcs (N, NE...CALM) (verbose)
        6 is for database debugging

        [[DeltaT]]
        calculate_deltaT: Whether to generate deltaT for the report page.
        Default is not to generate that data.
        This is a switch (boolean) to turn it on.

        [[PHPUnits]]
        tempConvert:
        speedConvert:
        pressConvert:
        rainConvert: These are all used to convert the database units to ones
        for display by the php generated report.
        Because we are bypassing weewx to generate the historical data, we
        can't utilize the inbuilt weewx functions for unit conversion therefore
        we need to affect them ourselves.
        This is performed (if needed) by specifying the conversion to be done
        from the [[PHPUnits]] section of the skin.conf file.
        The default is to perform no conversion, to accept the units as they
        are.
        """

        self.wxobs_version = wxobs_version
        self.wxobs_debug = int(self.generator.skin_dict['wxobs'].get(
            'wxobs_debug', '0'))

        self.send_inc = to_bool(self.generator.skin_dict['wxobs'].get(
            'send_include', True))
        # self.inc_path = self.generator.skin_dict['wxobs'].get(
        #    'include_path', '/usr/share/php')

        # intervals for display of results
        self.disp_interval = self.generator.skin_dict['wxobs'].get(
            'display_interval', '1800')
        self.arch_interval = self.generator.config_dict['StdArchive'].get(
            'archive_interval')
        # now decide whether intermediate reading will be averaged or ignored.
        self.display_type = self.generator.skin_dict['wxobs'].get(
            'display_type', 'single')
        if self.display_type == 'single':
            self.disp_single = to_bool(True)
            # loginf("              %s single readings, %s " % (self.disp_single, self.display_type))
        elif self.display_type == 'average':
            self.disp_single = to_bool(False)
            self.arch_interval = self.disp_interval
            # loginf("              %s average readings, %s " % (self.disp_single, self.display_type))
        else:
            # loginf("                reverting to single readings, %s is not an option" % self.display_type)
            self.disp_single = to_bool(True)
        self.app_temp = self.generator.skin_dict['wxobs'].get(
            'app_Temp', 'windchill')
        self.php_zone = self.generator.skin_dict['wxobs'].get(
            'timezone', '')
        self.php_error = to_bool(self.generator.skin_dict['wxobs'].get(
            'show_php_errors', False))
        self.show_warning = to_bool(self.generator.skin_dict['wxobs']['DeltaT']
                                    .get('show_warning', True))
        self.want_delta = to_bool(self.generator.skin_dict['wxobs']['DeltaT']
                                  .get('calculate_deltaT', False))
        if not self.want_delta:
            self.show_warning = to_bool(self.generator.skin_dict['wxobs']
                                        ['DeltaT'].get('show_warning', False))

        # these variable are being used as a function names, thus the Case
        # abuse... usage! and the complaints from syntax checkers.
        self.tempConvert = self.generator.skin_dict['wxobs']['PHPUnits'].get(
            'temperature_convert', 'NTC')
        self.speedConvert = self.generator.skin_dict['wxobs']['PHPUnits'].get(
            'speed_convert', 'NSC')
        self.pressConvert = self.generator.skin_dict['wxobs']['PHPUnits'].get(
            'pressure_convert', 'NPC')
        self.rainConvert = self.generator.skin_dict['wxobs']['PHPUnits'].get(
            'rain_convert', 'NDC')

        self.shift_rain = to_bool(self.generator.skin_dict['wxobs']
                                  ['RainTiming'].get('shift_rain', False))
        # 32400 (rainday_start) == 9 hours == 9 a.m.
        self.rainday_start = self.generator.skin_dict['wxobs']['RainTiming'].get(
            'rain_start', '32400')
        # 32400 == 9 hours == 9 (start_label) a.m.
        self.start_label = self.generator.skin_dict['wxobs']['RainTiming'].get(
            'start_label', '9')


        # target_unit = METRICWX # Options are 'US', 'METRICWX', or 'METRIC'
        self.targ_unit = self.generator.config_dict['StdConvert'].get(
            'target_unit')

        # used for rsync of sqlite databases and include file to remote machines
        self.dest_dir = self.generator.skin_dict['wxobs']['Remote'].get(
            'dest_directory', '')
        if self.dest_dir:
            self.rsync_user = self.generator.skin_dict['wxobs']['Remote'] \
                .get('rsync_user', '')
            if not self.rsync_user:
                try:
                    self.rsync_user = self.generator.config_dict['StdReport'] \
                        ['RSYNC'].get('user', '')
                except:
                    if self.wxobs_debug >= 1:
                        logdbg("No rsync _user supplied?")

            self.rsync_server = self.generator.skin_dict['wxobs']['Remote'] \
                .get('rsync_server', '')
            if not self.rsync_server:
                try:
                    self.rsync_server = self.generator.config_dict['StdReport'] \
                        ['RSYNC'].get('server', '')
                except:
                    if self.wxobs_debug >= 1:
                        logdbg("No rsync server supplied?")
            # did we get anything that we can use?
            if not self.rsync_user or not self.rsync_server:
                self.dest_dir = ''
            else:
                # we did so we need these...
                self.rsync_options = self.generator.skin_dict['wxobs'] \
                    ['Remote'].get('rsync_options', '-ac')
                self.log_success = to_bool(self.generator.skin_dict['wxobs']
                                           ['Remote'].get('log_success', True))
                pass


        # prepare the database details and write the include file
        def_dbase = self.generator.config_dict['DataBindings'] \
            ['wx_binding'].get('database')
        if self.wxobs_debug == 5:
            logdbg("database is %s" % def_dbase)
#########################
# BEGIN TESTING ONLY:
# For use when testing sqlite transfer when a mysql database is the default archive
# Our normal mode of operation is False - ie: don't change a bloody thing!
# It won't be mentioned in the skin.conf description. You'll need to have seen this
# to know the switch exists!
        test_sqlite = to_bool(self.generator.skin_dict['wxobs']['Remote'].get(
            'test_withmysql', False))
        if test_sqlite:
            def_dbase = 'archive_sqlite'
# END TESTING ONLY:
#########################
        if def_dbase == 'archive_mysql':
            self.dbase = 'mysql'
            self.mysql_base = self.generator.config_dict['Databases'] \
                [def_dbase].get('database_name')
            id_match = self.mysql_base
            self.mysql_host = self.generator.config_dict['DatabaseTypes'] \
                ['MySQL'].get('host')
            self.mysql_user = self.generator.config_dict['DatabaseTypes'] \
                ['MySQL'].get('user')
            self.mysql_pass = self.generator.config_dict['DatabaseTypes'] \
                ['MySQL'].get('password')
            v_al = ["<?php\n $php_dbase = '%s';\n $php_mysql_base = '%s';\n"
                    " $php_mysql_host = '%s';\n $php_mysql_user = '******';\n"
                    " $php_mysql_pass = '******';\n" %
                    (self.dbase, self.mysql_base, self.mysql_host,
                     self.mysql_user, self.mysql_pass)]
            if self.wxobs_debug == 6:
                loginf("mysql database is %s, %s, %s, %s" % (
                    self.mysql_base, self.mysql_host,
                    self.mysql_user, self.mysql_pass))
        elif def_dbase == 'archive_sqlite':
            self.dbase = 'sqlite'
            self.sq_dbase = self.generator.config_dict['Databases'] \
                [def_dbase].get('database_name')
            id_match = self.sq_dbase[:-4]
            self.sq_root = self.generator.config_dict['DatabaseTypes'] \
                ['SQLite'].get('SQLITE_ROOT')

            self.sqlite_db = ("%s/%s" % (self.sq_root, self.sq_dbase))
            v_al = ["<?php\n $php_dbase = 'sqlite';\n $php_sqlite_db = '%s';\n" %
                    self.sqlite_db]

            if self.wxobs_debug == 6:
                loginf("sqlite database is %s, %s, %s" % (
                    self.sq_dbase, self.sq_root, self.sqlite_db))

        # phpinfo.php shows include_path as .:/usr/share/php, we'll put it
        # in there and hopefully that will work for most users.
        # I use/prefer /tmp/wxobs_inc.inc

        inc_file = ("wxobs_%s.inc" % id_match)
        if self.dest_dir != '':
            # create an empty index.html to obscure directory listing
            self.zero_html = self.dest_dir+"/index.html"
            if not os.path.exists(self.dest_dir):
                os.makedirs(self.dest_dir, mode=0o0755)
            if not os.path.isfile(self.zero_html):
                with open(self.zero_html, 'a') as z:  # Create file if does not exist
                    pass  # and auto close it
            # we are rsyncing remotely
            # And going to change all the remote paths, the include_path has lost
            # its precedence.
            self.inc_path = self.dest_dir
            self.include_file = ("%s/%s" % (self.inc_path, inc_file))
            # preempt inevitable warning/exception when using test_sqlite = False
            self.sq_dbase = self.generator.config_dict['Databases'] \
                [def_dbase].get('database_name')

            new_location = (self.dest_dir+"/"+self.sq_dbase)
            v_al = ["<?php\n $php_dbase = 'sqlite';\n $php_sqlite_db = '%s/%s';" %
                    (self.dest_dir, self.sq_dbase)]

            # symlink database to new location here, which will be mirrored on the
            # remote serve. This rallows local usage of wxobs as well as remote
            org_location = (self.sq_root+"/"+self.sq_dbase)
            if not os.path.isfile(new_location):
                if self.wxobs_debug == 2:
                    loginf("database, attempting to \'symlink %s %s\'"
                           % (org_location, new_location))
                try:
                    os.symlink(org_location, new_location)
                except OSError as e:
                    logerr("error creating database symlink %s" % e)

            try:
                if not os.access(self.include_file, os.W_OK):
                    os.makedirs(self.inc_path)
            except OSError as e:
                if e.errno == os.errno.EEXIST:
                    pass
        else:
            # All other cases, local or remote...
            # we are going to retain the defaults values, maybe a slight tweak.
            # use the skin.conf include_path, either default or the override.
            self.inc_path = self.generator.skin_dict['wxobs'].get(
                'include_path', '/usr/share/php')
            # phpinfo.php include_path is referenced but missing in some cases - php7.3?
            # possibly installed with php-pear ?
            # FIXME: a quick and harmless fix is to create it.
            if not os.path.exists(self.inc_path):
                os.makedirs(self.inc_path, mode=0o0755)
                loginf("Created %s" % self.inc_path)
            self.include_file = ("%s/%s" % (self.inc_path, inc_file))

        #if self.send_inc and self.dest_dir != '':
        if self.send_inc:
            php_inc = open(self.include_file, 'w')
            php_inc.writelines(v_al)
            if self.php_zone != '':
                t_z = ("\n ini_set(\"date.timezone\", \"%s\");" % self.php_zone)
                if self.wxobs_debug == 2:
                    loginf("timezone is set to %s" % t_z)
                php_inc.write(t_z)
            if self.php_error:
                php_err = ('\n ini_set(\'display_errors\', 1);'
                           '\n ini_set(\'display_startup_errors\', 1);'
                           '\n error_reporting(E_ALL);')
                if self.wxobs_debug == 2:
                    loginf("php error reporting is set: %s" % php_err)
                php_inc.writelines(php_err)
            php_inc.close()

        # use rsync to transfer database remotely, but ONLY if requested
        if def_dbase == 'archive_sqlite' and self.dest_dir != '':
            # honor request to move destination directories (same for both)
            # create and redefine as appropriate
            if self.dest_dir:
                self.sq_root = self.dest_dir
            # database transfer
            db_loc_file = "%s" % (self.sqlite_db)
            db_ssh_str = "%s@%s:%s/" % (self.rsync_user, self.rsync_server,
                                        self.sq_root)
            wxrsync(self.rsync_user, self.rsync_server, self.rsync_options,
                    db_loc_file, self.zero_html, db_ssh_str, self.sq_root,
                    self.wxobs_debug, self.log_success)

            if self.send_inc:
                # perform include file transfer if wanted, zero_html just
                # fills a slot here.
                inc_loc_file = "%s" % (self.include_file)
                inc_ssh_str = "%s@%s:%s/" % (self.rsync_user, self.rsync_server,
                                             self.inc_path)
                wxrsync(self.rsync_user, self.rsync_server, self.rsync_options,
                        inc_loc_file, self.zero_html, inc_ssh_str,
                        self.inc_path, self.wxobs_debug, self.log_success)
示例#19
0
 def __init__(self, generator):
     SearchList.__init__(self, generator)
示例#20
0
 def __init__(self, generator):  # 2
     SearchList.__init__(self, generator)
     self.color_tables = self.generator.skin_dict.get('Colorize', {})