Comments (9)
Actually, let me amend that. It should be easier to implement a tell
method than I said. Just call lseek
with whence = SEEK_CUR
and an offset of 0 bytes; this will return the current offset without changing it.
from pysmbc.
Just wanted to gently nudge again on this issue - I don't mean to pester, I know what it's like to support open source code, I'm just hoping to for an answer about whether this might even be possible. Thanks for your time.
from pysmbc.
I have no idea to add flush() and tell() with libsmbclient.
https://github.com/samba-team/samba/blob/master/source3/include/libsmbclient.h
If I'm in the same situation as you, I'll transfer the complete file written locally to the remote.
from pysmbc.
OK, thanks for the reply. Uploading whole files is a potential solution, but one I am hoping to avoid for a few reasons. The biggest reason is that the arrays I am hoping to load / save are quite large, so saving to disk and then uploading takes substantially longer than directly uploading, and quickly creates a large cache (e.g. on cluster machines running jobs). But I can work with it. Thanks again for your useful code.
from pysmbc.
The obvious answer is to wrap an smbc.File
in your own file-like object. Every time write
is called, count up the number of bytes written before passing it on. And of course also keep track of seek
calls. Then you can implement tell
to return the current position.
As for flush
, I assume that libsmbclient doesnโt implement buffering. So either implement flush as a noop, or (more complicated) manage your own buffering.
(Duck typing FTW!)
from pysmbc.
Workaround:
class SmbcFileWrapper(object):
def __init__(self, obj):
self.obj = obj
def __getattr__(self, name):
return getattr(self.obj, name)
def flush(self):
pass
def tell(self):
return self.obj.seek(0, os.SEEK_CUR)
from pysmbc.
I added a custom read
function to fix another issue: #46 (comment)
from pysmbc.
I did 2 pull requests (flush, tell) + a fix for the read function.
Here is a branch with the 3 PR merged together: https://github.com/frafra/pysmbc/tree/nina-fixes
from pysmbc.
Upstream bug report for tell
: https://bugzilla.samba.org/show_bug.cgi?id=14383
Upstream bug report for flush
: https://bugzilla.samba.org/show_bug.cgi?id=14384
from pysmbc.
Related Issues (20)
- pip install pysmbc HOT 1
- How to select a new protocol such as SMB2 or SMB3 HOT 1
- Fix Some Holes In Error Checking And Potential Memory Leaks HOT 2
- Rework Module Init To Be Table-Driven
- Context.stat() and File.fstat() Should Return os.stat_result HOT 3
- Support with/as
- How do you get a list of shared printers?
- no new release HOT 4
- read() without a parameter makes seek fail HOT 1
- Add seekable method
- pip install fails to install v1.0.22 HOT 6
- Deprecation Warning HOT 1
- Rework Context.getxattr() To Only Allocate Needed Buffer Space HOT 4
- Cannot open directory "." with opendir()
- unable to install pysmbc on windows HOT 1
- Issuing commands / printing
- setxattr() input and getxattr() output doesn't match HOT 5
- Information about control bit is missing in getxattr response HOT 2
- getxattr() fails to retrieve the ACLs for SMB Azure File Share
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pysmbc.