Results 1 to 1 of 1

Thread: [Help] Trying to download a file from web (Python Plugin Enigma2)

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    1
    Thanks
    1
    Thanked 1 Time in 1 Post

    [Help] Trying to download a file from web (Python Plugin Enigma2)

    Hello guys im trying to download a .txt file from web using this code as a plugin but im getting the download error.
    Can any of you spot anything that might cause this?
    ################################# ################################# #########
    from Screens.Screen import Screen
    from Screens.MessageBox import MessageBox
    from Components.Label import Label
    from Components.ActionMap import ActionMap
    from Plugins.Plugin import PluginDescriptor
    from twisted.web.client import downloadPage
    from Tools.Directories import fileExists
    ################################# ################################# #########
    class getFilefromUrl(object):
    def __init__(self, session, url=None, path=None):
    self.path = path
    self.session = session
    self.download(url, path)


    def download(self, url, path):
    downloadPage(url, path).addCallback(self.downloadDo ne).addErrback(self.downloadError )

    def downloadError(self, raw):
    print "[e2Fetcher.fetchPage]: download Error", raw
    self.session.open(MessageBox, text = _("Error downloading: ") + self.path, type = MessageBox.TYPE_ERROR)

    def downloadDone(self,raw):
    print "[e2Fetcher.fetchPage]: download done", raw


    class startscreen(Screen):
    skin = """
    <screen position="130,150" size="460,150" title="My title" >
    <widget name="myText" position="10,20" size="400,50"
    valign="center" halign="center" zPosition="2" foregroundColor="white"
    font="Regular;22"/>
    <widget name="myRedBtn" position="10,110" size="100,40"
    backgroundColor="red" valign="center" halign="center" zPosition="2"
    foregroundColor="white" font="Regular;20"/>
    <widget name="myGreenBtn" position="120,110" size="100,40"
    backgroundColor="green" valign="center" halign="center" zPosition="2"
    foregroundColor="white" font="Regular;20"/>
    </screen>"""
    def__init__(self, session, args = 0):
    self.session =session
    Screen.__init__(self, session)
    self["myText"] =Label("Press the Green or OK button to start\n the update.")
    self["myRedBtn"] =Label(_("Cancel"))
    self["myGreenBtn"] =Label(_("OK"))
    self["myActionsMap"] =ActionMap(["SetupActions", "ColorActions"],
    {
    "ok": self.startPicplayer,
    "green": self.startPicplayer,
    "red": self.close,
    "cancel": self.close,
    }, -1)
    defupdate(self):
    getFilefromUrl(session,"http://www.theaddressthatmytxtfileisuplo aded.com/nameoffile.txt", "/tmp/textfile.txt")
    ################################# ################################# #########
    defmain(session, **kwargs):
    session.open(startscreen)
    ################################# ################################# #########
    defPlugins(**kwargs):
    returnPluginDescriptor(
    name="txtfiledownload",
    description="no description for now",
    where =PluginDescriptor.WHERE_PLUGINMEN U,
    icon="./icon.png",
    fnc=main)

  2. The Following User Says Thank You to LibTiff For This Useful Post:

    avavynova (30-06-2017)

  3.    Advert



Similar Threads

  1. Dreambox Enigma2 Plugins, Python & tus
    By oldfart in forum Python
    Replies: 0
    Last Post: 11-02-2013, 10:10 PM
  2. My Plugin download server
    By DJBlu in forum AZBox HD Newbie Questions
    Replies: 62
    Last Post: 05-02-2013, 05:23 PM
  3. Question How to download enigma2 way on your azbox premium hd
    By khaled almanaseer in forum AzBox HD E2 Newbie Questions
    Replies: 4
    Last Post: 16-02-2012, 06:15 PM
  4. New AAF Enigma2 Summer2011 Image - full USB download here
    By ManikM in forum S4000 HD Enigma2 Images
    Replies: 4
    Last Post: 27-09-2011, 01:48 PM
  5. Multicas 1.60D-C01 Plugin Download
    By Smudger in forum AZBox HD Newbie Questions
    Replies: 12
    Last Post: 19-10-2009, 10:46 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •