Example #1
0
def cli(sis, io):
    """
    The CLI inteface. Just powerschool extracts
    for now. 
    """
    if sis.lower() == 'powerschool':
        logger.info("Beginging PowerSchool Export")
        psa = PowerSchoolAdmin()
        psf = PowerSchoolFrontend()

        # Login to Admin, upload HTML 
        psa.login()
        psa._go_to_custom_pages()
        # ps doesn't error if folder exists, so fine to run everytime
        psa._add_eduextractor_folder() 
        
        # Now let's prep our queries and files
        sql_queries = os.listdir('./eduextractor/sis/powerschool/sql/')
        
        # Okay, Content time
        top_file = open('./eduextractor/sis/powerschool/html/top.html',
                        'r')
        bottom_file = open('./eduextractor/sis/powerschool/html/bottom.html',
                           'r')
        top = top_file.read()
        bottom = bottom_file.read()
        
        # Create the pages
        for query in sql_queries:
            page_name = query.replace('.sql', '.html')
            logger.info("Creating page " + page_name)
            psa._create_html_page(page_name)
            logger.info("Page " + page_name + " created.")

        # waiting for publishing
        prompt = "Please click Publish on every new page in /eduextractor. Y/n"
        pub_status = raw_input(prompt)
        if not pub_status:
            logger.error("You haven't published anything yet. ")
        for query in sql_queries:
            page_name = query.replace('.sql', '.html')
            query_content_f = open('./eduextractor/sis/powerschool/sql/' + 
                                   query, 'r')
            query_content = query_content_f.read()
            content = top + query_content + bottom
            psa._publish_custom_page(page_name, content)

        # go to frontend
        psf.login()
        logger.info('Downloading tables')
        for query in sql_queries:
            page_name = query.replace('.sql', '.html')
            df = psf._download_html_table(page_name)
            df.to_csv('/tmp/' + query + '.csv')
Example #2
0
class test_powerschool_frontend(unittest.TestCase):
    
    @classmethod
    def setUp(self):
        self.ps = PowerSchoolFrontend()

    def testLogin(self):
        """
        Test if we can login
        """
        self.ps.login()
        self.assertEqual(self.ps.dr.title, u'Start Page')
Example #3
0
 def setUp(self):
     self.ps = PowerSchoolFrontend()