Search Results

Search found 13 results on 1 pages for 'zubin71'.

Page 1/1 | 1 

  • openvpn restriction

    - by zubin71
    hi, ive set up an openvpn server at my place and handed out a certificate to a client who has an openvpn client at his place. however i require that he should be able to connect to the vpn server only from one ip(his current one). how can i do this?

    Read the article

  • openvpn restriction

    - by zubin71
    hi, ive set up an openvpn server at my place and handed out a certificate to a client who has an openvpn client at his place. however i require that he should be able to connect to the vpn server only from one ip(his current one). how can i do this?

    Read the article

  • using a "temporary files" folder in python

    - by zubin71
    I recently wrote a script which queries PyPI and downloads a package; however, the package gets downloaded to a user defined folder. I`d like to modify the script in such a way that my downloaded files go into a temporary folder, if the folder is not specified. The temporary-files folder in *nix machines is "/tmp" ; would there be any Python method I could use to find out the temporary-files folder in a particular machine? If not, could someone suggest an alternative to this problem?

    Read the article

  • Download-from-PyPI-and-install script

    - by zubin71
    Hello, I have written a script which fetches a distribution, given the URL. After downloading the distribution, it compares the md5 hashes to verify that the file has been downloaded properly. This is how I do it. def download(package_name, url): import urllib2 downloader = urllib2.urlopen(url) package = downloader.read() package_file_path = os.path.join('/tmp', package_name) package_file = open(package_file_path, "w") package_file.write(package) package_file.close() I wonder if there is any better(more pythonic) way to do what I have done using the above code snippet. Also, once the package is downloaded this is what is done: def install_package(package_name): if package_name.endswith('.tar'): import tarfile tarfile.open('/tmp/' + package_name) tarfile.extract('/tmp') import shlex import subprocess installation_cmd = 'python %ssetup.py install' %('/tmp/'+package_name) subprocess.Popen(shlex.split(installation_cmd) As there are a number of imports for the install_package method, i wonder if there is a better way to do this. I`d love to have some constructive criticism and suggestions for improvement. Also, I have only implemented the install_package method for .tar files; would there be a better manner by which I could install .tar.gz and .zip files too without having to write seperate methods for each of these?

    Read the article

  • Cython Speed Boost vs. Usability

    - by zubin71
    I just came across Cython, while I was looking out for ways to optimize Python code. I read various posts on stackoverflow, the python wiki and read the article "General Rules for Optimization". Cython is something which grasps my interest the most; instead of writing C-code for yourself, you can choose to have other datatypes in your python code itself. Here is a silly test i tried, #!/usr/bin/python # test.pyx def test(value): for i in xrange(value): i**2 if(i==1000000): print i test(10000001) $ time python test.pyx real 0m16.774s user 0m16.745s sys 0m0.024s $ time cython test.pyx real 0m0.513s user 0m0.196s sys 0m0.052s Now, honestly, i`m dumbfounded. The code which I have used here is pure python code, and all I have changed is the interpreter. In this case, if cython is this good, then why do people still use the traditional Python interpretor? Are there any reliability issues for Cython?

    Read the article

  • python unittest howto

    - by zubin71
    I`d like to know how I could unit-test the following module. def download_distribution(url, tempdir): """ Method which downloads the distribution from PyPI """ print "Attempting to download from %s" % (url,) try: url_handler = urllib2.urlopen(url) distribution_contents = url_handler.read() url_handler.close() filename = get_file_name(url) file_handler = open(os.path.join(tempdir, filename), "w") file_handler.write(distribution_contents) file_handler.close() return True except ValueError, IOError: return False

    Read the article

  • Pause-able download

    - by zubin71
    Hello, I have an Apache server running which hosts a php web application. Also, its provides provisions for downloading a file of size around 900MB from it. However, while testing the application I found out that its not possible to pause the downloads and resume them later on. Could someone help me? Is it an apache property I must change?

    Read the article

  • difference in logging mechanism: API and application(python)

    - by zubin71
    I am currently writing an API and an application which uses the API. I have gotten suggestions from people stating that I should perform logging using handlers in the application and use a "logger" object for logging from the API. In light of the advice I received above, is the following implementation correct? class test: def __init__(self, verbose): self.logger = logging.getLogger("test") self.logger.setLevel(verbose) def do_something(self): # do something self.logger.log("something") # by doing this i get the error message "No handlers could be found for logger "test" The implementation i had in mind was as follows: #!/usr/bin/python """ .... .... create a logger with a handler .... .... """ myobject = test() try: myobject.do_something() except SomeError: logger.log("cant do something") Id like to get my basics strong, id be grateful for any help and suggestions for code you might recommend I look up. Thnkx!

    Read the article

  • unit test for proxy checking

    - by zubin71
    Proxy configuration of a machine can be easily fetched using def check_proxy(): import urllib2 http_proxy = urllib2.getproxies().get('http') I need to write a test for the above written function. In order to do that I need to:- Set the system-wide proxy to an invalid URL during the test(sounds like a bad idea). Supply an invalid URL to http_proxy. How can I achieve either of the above?

    Read the article

  • supply inputs to python unittests

    - by zubin71
    I`m relatively new to the concept of unit-testing and have very little experience in the same. I have been looking at lots of articles on how to write unit-tests; however, I still have difficulty in writing tests where conditions like the following arise:- Test user Input. Test input read from a file. Test input read from an environment variable. Itd be great if someone could show me how to approach the above mentioned scenarios; itd still be awesome if you could point me to a few docs/articles/blog posts which I could read.

    Read the article

  • windows service

    - by zubin71
    I need to write a windows service which executes an application after a certain amount of time. I have checked out the code in MSDN and found an example in which the System.ServiceProcess.ServiceBase class is sub-classed. I did the following. created a new C# console application copied the code from the MSDN example Run I get the following error The type or namespace name 'ServiceProcess' does not exist in the namespace 'System'(are you missing an assembly reference?) As i had copied the example from MSDN, i have no idea why the code still does not work. This is my first experience writing services and i`d love some guidance. thnkx!

    Read the article

  • Interpreted vs. Compiled vs. Late-Binding

    - by zubin71
    Python is compiled into an intermediate bytecode(pyc) and then executed. So, there is a compilation followed by interpretation. However, long-time Python users say that Python is a "late-binding" language and that it should`nt be referred to as an interpreted language. How would Python be different from another interpreted language? Could you tell me what "late-binding" means, in the Python context? Java is another language which first has source code compiled into bytecode and then interpreted into bytecode. Is Java an interpreted/compiled language? How is it different from Python in terms of compilation/execution? Java is said to not have, "late-binding". Does this have anything to do with Java programs being slighly faster than Python? Itd be great if you could also give me links to places where people have already discussed this; id love to read more on this. Thank you.

    Read the article

  • python django automated data addition

    - by zubin71
    I have a script which reads data from a csv file. I need to store the data into a database which has already been created as $ python manage.py syncdb so, that automated data entry is possible in an easier manner, as available in the django shell.

    Read the article

1