Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #642 from kivy/smb

Smb support for Loader using PySMB
  • Loading branch information...
commit f76213090ca9129b069a28c9e3d992704cd75133 2 parents fd9b0d4 + 8a6a200
@tito tito authored
Showing with 18 additions and 4 deletions.
  1. +17 −3 kivy/loader.py
  2. +1 −1  kivy/uix/image.py
View
20 kivy/loader.py
@@ -126,7 +126,7 @@ def _load(self, parameters):
return
if load_callback is not None:
data = load_callback(filename)
- elif proto in ('http', 'https', 'ftp'):
+ elif proto in ('http', 'https', 'ftp', 'smb'):
data = self._load_urllib(filename)
else:
data = self._load_local(filename)
@@ -147,6 +147,16 @@ def _load_urllib(self, filename):
'''(internal) Loading a network file. First download it, save it to a
temporary file, and pass it to _load_local()'''
import urllib2
+ proto = filename.split(':', 1)[0]
+ if proto == 'smb':
+ try:
+ # note: it's important to load SMBHandler every time
+ # otherwise the data is occasionaly not loaded
+ from smb.SMBHandler import SMBHandler
+ except ImportError:
+ Logger.warning(
+ 'Loader: can not load PySMB: make sure it is installed')
+ return
import tempfile
data = None
try:
@@ -155,8 +165,12 @@ def _load_urllib(self, filename):
_out_osfd, _out_filename = tempfile.mkstemp(
prefix='kivyloader', suffix=suffix)
- # read from internet
- fd = urllib2.urlopen(filename)
+ if proto == 'smb':
+ # read from samba shares
+ fd = urllib2.build_opener(SMBHandler).open(filename)
+ else:
+ # read from internet
+ fd = urllib2.urlopen(filename)
idata = fd.read()
fd.close()
View
2  kivy/uix/image.py
@@ -286,7 +286,7 @@ def on_source_load(self, value):
def is_uri(self, filename):
proto = filename.split('://', 1)[0]
- return proto in ('http', 'https', 'ftp')
+ return proto in ('http', 'https', 'ftp', 'smb')
def _on_tex_change(self, *largs):
if self._coreimage:
Please sign in to comment.
Something went wrong with that request. Please try again.