开发者

Is there anyway I can access File from Online SVN in python?

I've made a python module file and uploaded in the SVN Repo (say string_utl.py which does string related operation). Is the anyway that I can access the the file Direclty for the SVN. Though I checkout the file Locally from the SVN to my computer and access it from there. But that not the point. I'm thinking of a local repository where all of my coworkers can access and modify the code. I though add the Lsvn location in the sys.path list but it didn't worked.

I did it like this sys.path.append ("http://lsvn/svn/lsvn/QRM_Helper/Helpful_Script/");

But didn't worked.

I tried it another way like this urllib.urlopen(some_url) as I'm using Python 3 i开发者_如何学Ct said to use urllib2.urlopen() but in my case it didn't worked either. It gave the following error that the module doesn't exist.


Just install the pysvn module and then use normal SVN checkout, update, commit, etc.

You can't directly access the SVN backend datastore so please don't try.


If you are using python3,the url handling code is urllib.request.urlopen (BTW, it should not have said to use urllib2.urlopen). sys.path.append takes local system paths only. It cannot take the urls. You can checkout the module to your local system and point to that path. pysvn seems to be a way to programatically do svn operations using python, but still after you checkout the code, you should reference the directly the code is in, via local file-system path and add it to sys.path.


pip install -e svn+http://lsvn/svn/lsvn/QRM_Helper/Helpful_Script/#egg=local-name

will create a checkout it (into local-name/) and install links into your Python so an import just works, and svn update also just works - no reinstall needed. Caveat: don't know if that works on Windows. Oh, and you'll need a setup.py file for it to work.

This won't pull the module every time; you can use pysvn or just run svn update. But if you have more than one dependency, installing them with Pip will save your sanity :).


I just got the answer. I'll use the Pysvn to checkout the repo to a local folder. And I'll add the folder to sys.path list. Using this I can access the folders module. Thank everyone for helping me out

But I've a slight problem... I didn't had the admin right in my office computer(I'm using windows) so I installed the pysvn in my laptop and copied the lib files from my laptop to my office computer.. Though I can pysvn in my computer (Office comp).but the Python crashes for no certain reason when I access Pysvn.. Is the copy paste could be the reason for that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜