コード例 #1
0
ファイル: FeedCommander.py プロジェクト: farukrana/RSSTracker
 def __init__(self):
     Resource.__init__(self)
     self.list_of_feeds = []
     self.connectDB = ConnectFeedDB()
     self.connectDB.return_all_feeds()  #force reload of table information
     self.value = "test"
     self.html = self.create_html()
     self.feed_gen = [x for x in self.connectDB.return_all_feeds()]
     self.feeds = ""
     self.html_feeds()
     self.list_of_all_feeds = []
     self.all_feed_objects()
コード例 #2
0
ファイル: FeedStatus.py プロジェクト: nammer/RSSTracker
class ModifyFeed():
    def __init__(self):
        self.connectDB = ConnectFeedDB()
        
    def mod(self, all_feeds, bulk_feeds, action):
        self.all = all_feeds
        self.bulk_feeds = bulk_feeds
        
        for feed in range(0, len(self.bulk_feeds), 1):
            value = bulk_feeds[feed]
            for i in self.all:
                if i['id'] == int(value):
                    i['URL']
                else:
                    pass
        
        if action == 'delete_feeds':
            self.del_feeds(self.bulk_feeds)
        elif action == 'check_now':
            self.check_feeds(self.all, self.bulk_feeds)
        elif action == 'activate':
            self.activate(self.bulk_feeds)
        elif action == 'deactivate':
            self.deactivate(self.bulk_feeds)
        else:
            print action
            
    def del_feeds(self, bulk_feeds):
        for i in bulk_feeds:
            self.connectDB.del_feedBY('id', i)
    
    def check_feeds(self, all_feeds, bulk_feeds):
        for feed in range(0, len(bulk_feeds), 1):
            value = bulk_feeds[feed]
            for i in all_feeds:
                if i['id'] == int(value):
                    url = i['URL']
                    try:
                        self.connectDB.check_feed(id=value)
                        
                    except:
                        raise
                else:
                    pass
            
    def activate(self, bulk_feeds):
        for i in bulk_feeds:
            self.connectDB.activate_feed(i)
            
    def deactivate(self, bulk_feeds):
        for i in bulk_feeds:
            self.connectDB.deactivate_feed(i)
コード例 #3
0
class ModifyFeed():
    def __init__(self):
        self.connectDB = ConnectFeedDB()

    def mod(self, all_feeds, bulk_feeds, action):
        self.all = all_feeds
        self.bulk_feeds = bulk_feeds

        for feed in range(0, len(self.bulk_feeds), 1):
            value = bulk_feeds[feed]
            for i in self.all:
                if i['id'] == int(value):
                    i['URL']
                else:
                    pass

        if action == 'delete_feeds':
            self.del_feeds(self.bulk_feeds)
        elif action == 'check_now':
            self.check_feeds(self.all, self.bulk_feeds)
        elif action == 'activate':
            self.activate(self.bulk_feeds)
        elif action == 'deactivate':
            self.deactivate(self.bulk_feeds)
        else:
            print action

    def del_feeds(self, bulk_feeds):
        for i in bulk_feeds:
            self.connectDB.del_feedBY('id', i)

    def check_feeds(self, all_feeds, bulk_feeds):
        for feed in range(0, len(bulk_feeds), 1):
            value = bulk_feeds[feed]
            for i in all_feeds:
                if i['id'] == int(value):
                    url = i['URL']
                    try:
                        self.connectDB.check_feed(id=value)

                    except:
                        raise
                else:
                    pass

    def activate(self, bulk_feeds):
        for i in bulk_feeds:
            self.connectDB.activate_feed(i)

    def deactivate(self, bulk_feeds):
        for i in bulk_feeds:
            self.connectDB.deactivate_feed(i)
コード例 #4
0
ファイル: FeedCommander.py プロジェクト: nammer/RSSTracker
 def __init__(self):
     Resource.__init__(self)
     self.list_of_feeds = []
     self.connectDB = ConnectFeedDB()
     self.connectDB.return_all_feeds()#force reload of table information
     self.value = "test"
     self.html = self.create_html()
     self.feed_gen = [x for x in self.connectDB.return_all_feeds()]
     self.feeds = ""
     self.html_feeds()        
     self.list_of_all_feeds = []
     self.all_feed_objects()
コード例 #5
0
ファイル: FeedStatus.py プロジェクト: nammer/RSSTracker
 def __init__(self):
     self.connectDB = ConnectFeedDB()
コード例 #6
0
ファイル: FeedCommander.py プロジェクト: nammer/RSSTracker
class Feeds(Resource):
    def __init__(self):
        Resource.__init__(self)
        self.list_of_feeds = []
        self.connectDB = ConnectFeedDB()
        self.connectDB.return_all_feeds()#force reload of table information
        self.value = "test"
        self.html = self.create_html()
        self.feed_gen = [x for x in self.connectDB.return_all_feeds()]
        self.feeds = ""
        self.html_feeds()        
        self.list_of_all_feeds = []
        self.all_feed_objects()

        
    def create_html(self):    
        self.html = """
        <html>
        <body bgcolor="black" text="white">
        <center>
        <form name="feeds" method=POST> 
        <table border=2 cellpadding=5>
            <tr>
                <td>Select</td>
                <td>Feed ID</td>
                <td>Feed Type</td>
                <td>URL</td>
                <td>Active?</td>
                <td>Date Added</td>
                <td>Date Last Checked</td>
            </tr>
            {0} 
        </table>
        
        Bulk Action: <select name="BulkAction">
        <option value="bulk:None">No Bulk</option>
        <option value="bulk:delete_feeds">Delete</option>
        <option value="bulk:check_now">Check Now</option>
        <option value="bulk:activate">Activate</option>
        <option value="bulk:deactivate">Deactivate</option>
        </select>
        <input type="submit" value="Submit" />
        </center>
        </form>
        </body>
        </html>"""

        return self.html
    
    def html_feeds(self):
        for feed in self.feed_gen:
            self.feeds += "<tr>\n\t<td><input type=\"checkbox\" name=\"index_{0}\" value=\"FEED{0}:{0}\"/>".format(feed['id'])
            keys_ordered = ('id', 'URIType', 'URL', 'Active', 'Added', 'Last_Checked')
            self.list_of_feeds.append(feed)
            
            for key in keys_ordered:
                if key == 'Active':
                    if feed[key] == 1:
                        feed[key] = 'Active'
                    elif feed[key] == 0:
                        feed[key] = 'Deactive'
                        
                self.feeds += "<td>" + str(feed[key]) + "</td>"
            
            self.feeds += "</tr>"
        
    def inject_feeds(self):
        self.html = self.html.format(self.feeds)
        return self.html
    
    def feed_bulk_action(self, args):
        """The feed handler - as feed request come in, feeds are adjusted"""
        posted = args
        all_args = {} 
        for i in posted:
            i = i[0].split(":")
            all_args.update(dict([i]))
        
        self.all_feeds_list = []
        action = all_args['bulk']
        
        for i in all_args:
            if "FEED" in i:
                self.all_feeds_list.append(all_args[i])
        
        self.mod_status = ModifyFeed()
        self.mod_status.mod(self.list_of_feeds, self.all_feeds_list, action)

    def all_feed_objects(self):                    
        for feed in self.feed_gen:
            self.list_of_all_feeds.append(FeedInformation(feed))
        
        print self.list_of_all_feeds
        
    def render_GET(self, request):
        if request.path == '/feeds':
            self.__init__()
            return self.inject_feeds()
    
    def render_POST(self, request):
        args = request.args.values()
        self.feed_bulk_action(args)
        return self.render_GET(request)
コード例 #7
0
 def __init__(self):
     self.connectDB = ConnectFeedDB()
コード例 #8
0
ファイル: FeedCommander.py プロジェクト: farukrana/RSSTracker
class Feeds(Resource):
    def __init__(self):
        Resource.__init__(self)
        self.list_of_feeds = []
        self.connectDB = ConnectFeedDB()
        self.connectDB.return_all_feeds()  #force reload of table information
        self.value = "test"
        self.html = self.create_html()
        self.feed_gen = [x for x in self.connectDB.return_all_feeds()]
        self.feeds = ""
        self.html_feeds()
        self.list_of_all_feeds = []
        self.all_feed_objects()

    def create_html(self):
        self.html = """
        <html>
        <body bgcolor="black" text="white">
        <center>
        <form name="feeds" method=POST> 
        <table border=2 cellpadding=5>
            <tr>
                <td>Select</td>
                <td>Feed ID</td>
                <td>Feed Type</td>
                <td>URL</td>
                <td>Active?</td>
                <td>Date Added</td>
                <td>Date Last Checked</td>
            </tr>
            {0} 
        </table>
        
        Bulk Action: <select name="BulkAction">
        <option value="bulk:None">No Bulk</option>
        <option value="bulk:delete_feeds">Delete</option>
        <option value="bulk:check_now">Check Now</option>
        <option value="bulk:activate">Activate</option>
        <option value="bulk:deactivate">Deactivate</option>
        </select>
        <input type="submit" value="Submit" />
        </center>
        </form>
        </body>
        </html>"""

        return self.html

    def html_feeds(self):
        for feed in self.feed_gen:
            self.feeds += "<tr>\n\t<td><input type=\"checkbox\" name=\"index_{0}\" value=\"FEED{0}:{0}\"/>".format(
                feed['id'])
            keys_ordered = ('id', 'URIType', 'URL', 'Active', 'Added',
                            'Last_Checked')
            self.list_of_feeds.append(feed)

            for key in keys_ordered:
                if key == 'Active':
                    if feed[key] == 1:
                        feed[key] = 'Active'
                    elif feed[key] == 0:
                        feed[key] = 'Deactive'

                self.feeds += "<td>" + str(feed[key]) + "</td>"

            self.feeds += "</tr>"

    def inject_feeds(self):
        self.html = self.html.format(self.feeds)
        return self.html

    def feed_bulk_action(self, args):
        """The feed handler - as feed request come in, feeds are adjusted"""
        posted = args
        all_args = {}
        for i in posted:
            i = i[0].split(":")
            all_args.update(dict([i]))

        self.all_feeds_list = []
        action = all_args['bulk']

        for i in all_args:
            if "FEED" in i:
                self.all_feeds_list.append(all_args[i])

        self.mod_status = ModifyFeed()
        self.mod_status.mod(self.list_of_feeds, self.all_feeds_list, action)

    def all_feed_objects(self):
        for feed in self.feed_gen:
            self.list_of_all_feeds.append(FeedInformation(feed))

        print self.list_of_all_feeds

    def render_GET(self, request):
        if request.path == '/feeds':
            self.__init__()
            return self.inject_feeds()

    def render_POST(self, request):
        args = request.args.values()
        self.feed_bulk_action(args)
        return self.render_GET(request)