def download_file_from_net(url, filename): try: temp_dir = tempfile.gettempdir() save_dir = os.path.join(temp_dir, filename) image = urllib.URLopener() image.retrieve(url, save_dir) # install to the content folder scalalib.install_content(save_dir, subfolder='rss', autostart=False) scala5.ScalaPlayer.Log('Image ' + filename + ' downloaded from ' + url) except IOError as (errno, strerror): scala5.ScalaPlayer.LogExternalError(1000, 'I/O error({0})'.format(errno), strerror)
def save_data(xml_data): try: temp_dir = tempfile.gettempdir() save_dir = os.path.join(temp_dir, 'rss_data.xml') file_ = open(save_dir, 'w') file_.write(xml_data) file_.close() # install to the content folder scalalib.install_content(save_dir, subfolder='rss', autostart=True) scala5.ScalaPlayer.Log('XML rss data saved in player content directory') except IOError as (errno, strerror): scala5.ScalaPlayer.LogExternalError(1000, 'I/O error({0})'.format(errno), strerror)
import scalalib import sys svars = scalalib.sharedvars() if __name__ == '__main__': log = scalalib.get_logger(scala=0, con=1) scalalib.install_content( "C:\Documents and Settings\mgmiller\Desktop\dvd keyboard aerobed.txt", autostart=True) else: scalalib.install_content(svars.file_to_install, autostart=False)