Re: Pycharm offers only implementation of an abstract getter but not an abstract setter

2020-06-25 Thread zljubisic
You can freely leave Pycharm out of equation. In that case, there is a question how to force subclass to implement setter method? -- https://mail.python.org/mailman/listinfo/python-list

Re: Pycharm offers only implementation of an abstract getter but not an abstract setter

2020-06-25 Thread zljubisic
This also works with no errors: from abc import ABC, abstractmethod class C(ABC): @property @abstractmethod def my_abstract_property(self): pass @my_abstract_property.setter @abstractmethod def my_abstract_property(self, val): pass class D(C):

Re: Pycharm offers only implementation of an abstract getter but not an abstract setter

2020-06-24 Thread zljubisic
If my subclass is as this: from subclassing.abstract.BaseSomeAbstract import BaseSomeAbstract class ChildSomeAbstract(BaseSomeAbstract): @property def abs_prop(self): return self._abs_prop I can create an instance of it with no errors. So x = ChildSomeAbstract() works with no

Pycharm offers only implementation of an abstract getter but not an abstract setter

2020-06-24 Thread zljubisic
I would like to have an abstract class in which I will have an abstract property. So I used Pycharm in order to create an abstract (base) class: import abc class BaseSomeAbstract(abc.ABC): _abs_prop = None @property @abc.abstractmethod def abs_prop(self): return

Re: How to keep Dict[str, List] default method parameter as local to the method?

2020-06-14 Thread zljubisic
Thanks for the video. Now it is clear to me what has happened and why copy solves the problem. -- https://mail.python.org/mailman/listinfo/python-list

Re: How to keep Dict[str, List] default method parameter as local to the method?

2020-06-14 Thread zljubisic
params = {} if params is None else params.copy() has solved the problem. I have provided just a toy example here. Execute method actually takes dict[str, List]. List contains objects. Each object has two properties, so I have a logic that analyzes these properties and returns None or List as a

How to keep Dict[str, List] default method parameter as local to the method?

2020-06-14 Thread zljubisic
Hi, consider this example: from typing import Dict, List class chk_params: def execute(self, params: Dict[str, List] = None): if params is None: params = {} for k, v in params.items(): params[k] = [val + 10 for val in v] return

Re: Typing, how come that :int is not ensuring int parameter?

2020-06-11 Thread zljubisic
OK, as I can see nothing is enforced but I can use mypy and tests for the purpose. As I am using pycharm, looks like I need a plugin for mypy. There are two of them out there: non official: https://plugins.jetbrains.com/plugin/11086-mypy and official:

Typing, how come that :int is not ensuring int parameter?

2020-06-11 Thread zljubisic
Hi, If I run this code: class Property: def __init__(self, var: int): self.a: int = var @property def a(self): return self.__a @a.setter def a(self, var: int): if var > 0 and var % 2 == 0: self.__a = var else: self.__a

Do I need setters/getters in python?

2020-06-08 Thread zljubisic
Consider this code: class SetGet: _x = 1 @property def x(self): return self._x @x.setter def x(self, value): self._x = value class Dynamic: x = 1 if __name__ == '__main__': a = SetGet() print(f'x = {a.x}') a.x = 2 print(f'x =

Re: Can I have a class with property named "from"

2020-06-08 Thread zljubisic
Well the problem that I am facing with is, that I have to establish interface between python and outer system. Original question was about creation of input object (data that I have received from outer system). If I accept recommendation to use "from_" instead of "from", it could work, for

Can I have a class with property named "from"

2020-06-05 Thread zljubisic
Hi, if I define class like this one: class abc: def __init__(self): self._from = None @property def from(self): return self._from @from.setter def from(self, value): self._from = value I get the error SyntaxError: invalid syntax because of the

Re: Custom logging function

2020-05-29 Thread zljubisic
Hi Peter. Finally I got it. :) That's it. It works. Thanks. So, in each class, I will in init method execute: self.logger = logging.getLogger() and than everywhere use self.logger.debug('...') in order to produce the message. Best regards. --

Re: Custom logging function

2020-05-27 Thread zljubisic
> You create two stream handlers that both log to stderr -- one with > basicConfig() and one explicitly in your code. That's probably not what you > want. How can I just add terminator = '\r\n' to the code bellow? Where should I put it? import logging LOG_LEVEL = logging.getLevelName('DEBUG')

Re: Custom logging function

2020-05-26 Thread zljubisic
Furthermore, I must disable logging to stdout. -- https://mail.python.org/mailman/listinfo/python-list

Re: Custom logging function

2020-05-26 Thread zljubisic
Is this OK? import logging LOG_LEVEL = logging.getLevelName('DEBUG') logging.basicConfig(level=LOG_LEVEL, format='%(asctime)s %(levelname)s %(name)s %(funcName)-20s %(message)s', datefmt='%d.%m.%Y %H:%M:%S') stderr = logging.StreamHandler()

Custom logging function

2020-05-25 Thread zljubisic
Hi, I have a case in which I have to use custom function for logging. For example, all messages should go to stderr and end with '\r\n'. Can I somehow use standard python logging module but send all message to stderr with '\r\n' line endings? Regards --

How to design a class that will listen on stdin?

2020-05-23 Thread zljubisic
Hi, I have to talk to outer system by stdin/stdout. Each line that comes to stdin should be processed and its result returned back to stdout. Logging should go to stderr. How to design a class that will listed to stdin and call required methods in order to process the data? Regards --

Re: PyCharm, how to setup self contained subprojects

2020-05-23 Thread zljubisic
You are probably right. -- https://mail.python.org/mailman/listinfo/python-list

PyCharm, how to setup self contained subprojects

2020-05-21 Thread zljubisic
Hi, I should provide python code for (Spring) microservice patform. In microservice paradigm, each microservice should do a simple task, so python code beneath it should be very small. As a PyCharm (community) user, I don't know how to set up such development environment. Each microservice

Re: Replacing : with "${" at the beginning of the word and adding "}" at the end of the word

2018-10-03 Thread zljubisic
Yes it is. Thanks. > A slightly better solution would be: > > cnv_sel = re.sub(r":(\w+)", r"${\1}", sel) -- https://mail.python.org/mailman/listinfo/python-list

Re: Replacing : with "${" at the beginning of the word and adding "}" at the end of the word

2018-10-02 Thread zljubisic
I have to execute the same sql in two different programs. Each of them marks parameters differently. Anyway, I have found the solution. cnv_sel = re.sub(r"(:(.+?)\b)", r"${\2}", sel) Reagards. -- https://mail.python.org/mailman/listinfo/python-list

Replacing : with "${" at the beginning of the word and adding "}" at the end of the word

2018-10-02 Thread zljubisic
Hi, if I have a string: sql = """ where 1 = 1 and field = :value and field2 in (:list) """ I would like to replace every word that starts with ":" in the following way: 1. replace ":" with "${" 2. at the end of the word add "}" An example should look like this: where 1 = 1 and field =

Re: Saving application configuration to the ini file respecting order of sections/options and providing mechanism for (nested) complex objects

2018-08-22 Thread zljubisic
Thanks. As I can see python 3.7 is the best option. Thank you very very muchs for the code as well. Best regards. -- https://mail.python.org/mailman/listinfo/python-list

Saving application configuration to the ini file respecting order of sections/options and providing mechanism for (nested) complex objects

2018-08-21 Thread zljubisic
Hi, I am looking for a way to save ini file with application section/option combination. Something like the following: [Default] ROOT_DIR= /home/... RUN = True COUNTER = 5 LAST_VALUE = 5.6 TEST_FILES_LIST=['a.txt', 'b.txt', 'c.txt'] TEST_FILES_DICT={'CASE1' : ['a.txt', 'b.txt'], 'CASE2':

Re: Pandas cat.categories.isin list, is this a bug?

2018-05-17 Thread zljubisic
Hi Matt, > (Including python-list again, for lack of a reason not to. This > conversation is still relevant and appropriate for the general Python > mailing list -- I just meant that the pydata list likely has many more > Pandas users/experts, so you're more likely to get a better answer, >

Re: Pandas cat.categories.isin list, is this a bug?

2018-05-14 Thread zljubisic
On Monday, 14 May 2018 13:05:24 UTC+2, zlju...@gmail.com wrote: > Hi, > > I have dataframe with CRM_assetID column as category dtype: > > df.info() > > > RangeIndex: 1435952 entries, 0 to 1435951 > Data columns (total 75 columns): > startTime1435952 non-null object

Pandas cat.categories.isin list, is this a bug?

2018-05-14 Thread zljubisic
Hi, I have dataframe with CRM_assetID column as category dtype: df.info() RangeIndex: 1435952 entries, 0 to 1435951 Data columns (total 75 columns): startTime1435952 non-null object CRM_assetID 1435952 non-null category searching a

Re: Passing all pandas DataFrame columns to function as separate parameters

2018-05-02 Thread zljubisic
Thomas, thank you very very much, this was exactly what I needed. Thanks again and best regards. -- https://mail.python.org/mailman/listinfo/python-list

Passing all pandas DataFrame columns to function as separate parameters

2018-04-27 Thread zljubisic
Hi, I have pandas DataFrame with several columns. I have to pass all columns as separate parameter to a function. Something like this if I have 4 columns. f, p = stats.f_oneway(df_piv.iloc[:, 0], df_piv.iloc[:, 1], df_piv.iloc[:, 2], df_piv.iloc[:, 3]) As number of columns varies, how to do

Open (txt) editor and get its content

2018-04-19 Thread zljubisic
Hi, I have a script that should accept sql query as a parameter and change it in a way. For now I have a file in which I have put sql query and than python script opens it and do everything else. Is it possible to run python script that will open editor and let me paste sql query in the

Re: python 3 creating hard links on ntfs

2018-04-19 Thread zljubisic
Thanks guys. -- https://mail.python.org/mailman/listinfo/python-list

python 3 creating hard links on ntfs

2018-04-18 Thread zljubisic
Is it possible to create hard links on windows with ntfs? On linux I can use os.link, but how about windows? Regards. -- https://mail.python.org/mailman/listinfo/python-list

Re: Regex for changing :variable to ${variable} in sql query

2018-04-18 Thread zljubisic
On Wednesday, 18 April 2018 19:34:37 UTC+2, MRAB wrote: > > Hi, > > > > I have a sql query in which all variables declared as :variable should be > > changed to ${variable}. > > > > for example this sql: > > > > select * > > from table > > where ":x" = "1" and :y=2 > > and field in

Regex for changing :variable to ${variable} in sql query

2018-04-18 Thread zljubisic
Hi, I have a sql query in which all variables declared as :variable should be changed to ${variable}. for example this sql: select * from table where ":x" = "1" and :y=2 and field in (:string) and time between :from and :to should be translated to: select * from table where "${x}"

Re: Pandas, create new column if previous column(s) are not in [None, '', np.nan]

2018-04-12 Thread zljubisic
On Wednesday, 11 April 2018 21:19:44 UTC+2, José María Mateos wrote: > On Wed, Apr 11, 2018, at 14:48, zlj...com wrote: > > I have a dataframe: > > [...] > > This seems to work: > > df1 = pd.DataFrame( { 'A' : ['a', 'b', '', None, np.nan], > 'B'

Pandas, create new column if previous column(s) are not in [None, '', np.nan]

2018-04-11 Thread zljubisic
I have a dataframe: import pandas as pd import numpy as np df = pd.DataFrame( { 'A' : ['a', 'b', '', None, np.nan], 'B' : [None, np.nan, 'a', 'b', '']}) A B 0 a None 1 b NaN 2 a 3 None b 4 NaN I would like to create column C in

Re: Python loop and web server (bottle) in the same script (Posting On Python-List Prohibited)

2017-11-29 Thread zljubisic
Processing is I/O and CPU bound. :( -- https://mail.python.org/mailman/listinfo/python-list

Re: Python loop and web server (bottle) in the same script (Posting On Python-List Prohibited)

2017-11-24 Thread zljubisic
That's right. Update task has precedence. Looks like it is not an easy task. Regards. -- https://mail.python.org/mailman/listinfo/python-list

Python loop and web server (bottle) in the same script

2017-11-23 Thread zljubisic
I would like to have a script that collects data every minute and at the same time serve newly collected data as web pages. Timely collecting data is more important than serving web pages, so collecting data should have priority and should never be interrupted by serving web pages. My first

Re: Pandas to_html cannot apply style

2017-10-30 Thread zljubisic
> This is not an in-place operation: it returns a style which you can then > render. > > style = df.style.apply(function2, axis=1) > html = style.render() > > appears to work. After your suggestion, rows are properly colored, but now I have lost all table lines, font is smaller... Is there an

Re: Pandas to_html cannot apply style

2017-10-30 Thread zljubisic
> This is not an in-place operation: it returns a style which you can then > render. > > style = df.style.apply(function2, axis=1) > html = style.render() > > appears to work. This was a missing link. Thank you very very much Thomas. Regards and best wishes. --

pandas finding field difference between two dataframes

2017-10-30 Thread zljubisic
Hi, I have to compare two pandas dataframes and find difference between each row. For example, in the code bellow, rows with index 0 and 3 are intentionally different. Row 0 is different in field A, and row 3 is different in field 3. After merging dataframes, I can concentrate to the dfm with

Pandas to_html cannot apply style

2017-10-30 Thread zljubisic
Hi, the following code never applies style and I cannot figure out why. Can someone please help? import pandas as pd def function2(row): if row.A == True: color = '#FF' else: color = '#00FF00' background_color = 'background-color: {}'.format(color) return

Convert pandas series to string and datetime object

2017-09-21 Thread zljubisic
I have sliced the pandas dataframe end_date = df[-1:]['end'] type(end_date) Out[4]: pandas.core.series.Series end_date Out[3]: 48173 2017-09-20 04:47:59 Name: end, dtype: datetime64[ns] 1. How to get rid of index value 48173 and get only "2017-09-20 04:47:59" string? I have to call

Converting epoch to string in format yyyy-mm-dd, or maybe it is not necessary

2017-06-01 Thread zljubisic
I have a dataframe with epoh dates, something like this: df = pd.DataFrame( { 'epoch' : [1493928008, 1493928067, 1493928127, 1493928310, 1493928428, 1493928547]}) I want to create a new column with epoch converted to -mm-dd as string. Actually, I have a epoch column, and I would like to

Re: Pandas dataframe, how to find a very specific max values?

2017-05-31 Thread zljubisic
On Tuesday, 30 May 2017 22:33:50 UTC+2, Peter Otten wrote: > z...@gmail.com wrote: > > > I have a dataframe: > > > > > > df = pd.DataFrame({ > >'x': [3,4,5,8,10,11,12,13,15,16,18,21,24,25], > >'a': [10,9,16,4,21,5,3,17,11,5,21,19,3,9] > > }) > > > > df > > Out[30]: > > a x > >

Pandas dataframe, how to find a very specific max values?

2017-05-30 Thread zljubisic
I have a dataframe: df = pd.DataFrame({ 'x': [3,4,5,8,10,11,12,13,15,16,18,21,24,25], 'a': [10,9,16,4,21,5,3,17,11,5,21,19,3,9] }) df Out[30]: a x 0 10 3 19 4 2 16 5 34 8 4 21 10 55 11 63 12 7 17 13 8 11 15 95 16 10 21 18 11 19 21 12

pandas dataframe, find duplicates and add suffix

2017-03-28 Thread zljubisic
In dataframe import pandas as pd data = {'model': ['first', 'first', 'second', 'second', 'second', 'third', 'third'], 'dtime': ['2017-01-01_112233', '2017-01-01_112234', '2017-01-01_112234', '2017-01-01_112234', '2017-01-01_112234', '2017-01-01_112235', '2017-01-01_112235'], }

Re: pandas creating a new column based on row values

2017-03-28 Thread zljubisic
It works. Thank you very much. :) -- https://mail.python.org/mailman/listinfo/python-list

pandas creating a new column based on row values

2017-03-28 Thread zljubisic
This doesn't work: import pandas as pd def myfunc(): return 'Start_{}_{}_{}_{}_End'.format(df['coverage'], df['name'], df['reports'], df['year']) data = {'name': ['Jason', 'Molly', 'Tina', 'Jake', 'Amy'], 'year': [2012, 2012, 2013, 2014, 2014], 'reports': [4, 24, 31, 2,

Re: Extraction of model and date created tag from own picture/video recordings

2017-03-15 Thread zljubisic
I have done that. The best article I have found is: https://getpocket.com/a/read/1651596570 So far I have tried exifread, exiftool, mediainfo, but looks like I will have to combine several tools in order to get the information that I need. Major problem is with the model. Looks like every

Re: Extraction of model and date created tag from own picture/video recordings

2017-03-15 Thread zljubisic
On Tuesday, 14 March 2017 19:54:18 UTC+1, MRAB wrote: > It might be worth trying "ImageMagick". ImageMagick is only for pictures. :( Do you have a suggestion for videos? -- https://mail.python.org/mailman/listinfo/python-list

Extraction of model and date created tag from own picture/video recordings

2017-03-14 Thread zljubisic
I am looking for the way to extract two simple information from pictures/videos that I have recorded with different devices that I own: model (of the device that has recorded) and recordings (local) creation time. So far, I tried different approaches. I tried to use pymediainfo

Extraction of model and date created tag from own picture/video recordings

2017-03-14 Thread zljubisic
I am looking for the way to extract two simple information from pictures/videos that I have recorded with different devices that I own: model (of the device that has recorded) and recordings (local) creation time. So far, I tried different approaches. I tried to use pymediainfo

Re: json.loads(...) ValueError: Expecting value: line 1 column 1 (char 0)

2016-05-10 Thread zljubisic
That was it. Thanks guys for your help. Best regards. -- https://mail.python.org/mailman/listinfo/python-list

json.loads(...) ValueError: Expecting value: line 1 column 1 (char 0)

2016-05-09 Thread zljubisic
Hi, in python3 my variable looks like this: a = b'{"uuid":"5730e8666ffa02.34177329","error":""}' str(a) = 'b\'{"uuid":"5730e8666ffa02.34177329","error":""}\'' If I execute the following command I get the error: >>> json.loads(str(a)) Traceback (most recent call last): File "C:\Program Files

Re: How to see html code under the particular web page element?

2016-05-07 Thread zljubisic
> There's probably some Angular JS code involved with this. Look at the > source (not the page source, the source code in the developer's > tools). Is it possible to get that code using python? -- https://mail.python.org/mailman/listinfo/python-list

How to see html code under the particular web page element?

2016-05-07 Thread zljubisic
Hi, on page: https://hrti.hrt.hr/#/video/show/2203605/trebizat-prica-o-jednoj-vodi-i-jednom-narodu-dokumentarni-film there is a picture and in the middle of the picture there is a text "Prijavite se za gledanje!" If I open the page in firefox and then use menu Tools > Web developer > Page

Re: Python3 html scraper that supports javascript

2016-05-02 Thread zljubisic
> Why? As important as it is to show code, you need to show what actually > happens and what error message is produced. If you run the code you will see that html that I got doesn't have link to the flash video. I should somehow do something (press play video button maybe) in order to get html

Re: Python3 html scraper that supports javascript

2016-05-02 Thread zljubisic
I tried to use the following code: from bs4 import BeautifulSoup from selenium import webdriver PHANTOMJS_PATH = 'C:\\Users\\Zoran\\Downloads\\Obrisi\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe' url =

Python3 html scraper that supports javascript

2016-05-01 Thread zljubisic
Hi, can you please recommend to me a python3 library that I can use for scrapping JS that works on windows as well as linux? Regards. -- https://mail.python.org/mailman/listinfo/python-list

Re: How to download a flash video from this site?

2016-04-30 Thread zljubisic
On Friday, 29 April 2016 22:40:10 UTC+2, Chris Angelico wrote: > Since you're asking on this list, I'll assume you're using Beautiful > Soup and/or youtube-dl. You'll need to go into more detail about what > you're trying to do, and where the Python problem is. > > ChrisA The situation is very

How to download a flash video from this site?

2016-04-29 Thread zljubisic
Hi, I am looking for a way to download a flash video from the page: https://hrti.hrt.hr/#/video/show/2203605/trebizat-prica-o-jednoj-vodi-i-jednom-narodu-dokumentarni-film The html code bellow the page is fairly simple, but I can't figure out how to get the file. In case somebody have an

Re: How to handle exceptions properly in a pythonic way?

2015-11-09 Thread zljubisic
Hi, You are right. I am trying to address a few questions at the same time. As English is not my first language, I can only say that you have addressed them very well. Thanks. 1. Where to put the try/except block, inside or outside the function 2. How to deal with un-anticipated exceptions

Re: Getting response by email reply message

2015-11-09 Thread zljubisic
> You have a couple options that occur to me: > > 1) set up an SMTP server somewhere (or use the existing one you're > receiving this email at in the event you're getting it as mail > rather than reading it via NNTP or a web interface) to receive the > mail, then create a Python script to poll

Re: Getting response by email reply message

2015-11-09 Thread zljubisic
> I'm assuming this is a website. If so, why not use a form with a checkbox? One of ideas is to put two url's in the email, one for yes and the other one for no. I am also thinking about reading/parsing the reply mail. Regards. -- https://mail.python.org/mailman/listinfo/python-list

Getting response by email reply message

2015-11-09 Thread zljubisic
Hi, I know how to send an email, but I would like to be able to receive a reply and act accordingly. Mail reply should contain yes/no answer. I don't know whether email is appropriate for such function. Maybe better idea would be to have links in email body, one for yes, another for no that

Re: Getting response by email reply message

2015-11-09 Thread zljubisic
> If what you really need is a voting application, you can look at > https://github.com/mdipierro/evote which the PSF uses for its elections. It is not a voting application (I will have more than yes/no answers). I just want to keep an example simple. Anyway, I will look into voting application

Re: How to handle exceptions properly in a pythonic way?

2015-11-09 Thread zljubisic
Hi, > def get_html(...): > try: > ... actually go get the info > return info > except (ConnectionError, OSError, SocketError) as e: > raise ContentNotFoundError from e Personally, I never liked "early returns". I would rather used a variable and the last line in

Re: How to handle exceptions properly in a pythonic way?

2015-11-04 Thread zljubisic
> The best way is probably to do nothing at all, and let the caller handle > any exceptions. In that case every call of the get_html function has to be in the try/except block with many exceptions. Sometimes, it is enough just to know whether I managed to get the html or not. In that case, I

Re: How to handle exceptions properly in a pythonic way?

2015-11-04 Thread zljubisic
> Which would you prefer? So if I am just checking for the ConnectionError in get_html and a new exception arises, I will have traceback to the get_html function showing that unhandled exception has happened. Now I have to put additional exception block for managing the new exception in the

Re: How to handle exceptions properly in a pythonic way?

2015-11-04 Thread zljubisic
On Monday, 2 November 2015 21:59:45 UTC+1, Ian wrote: > I'm having a hard time understanding what question you're asking. :) I am really having a hard time to explain the problem as English is not my first language. > You > have a lot of discussion about where to handle exceptions, That's

How to handle exceptions properly in a pythonic way?

2015-11-02 Thread zljubisic
Let's say that I have the following simple function: def get_html(url): wpage = requests.get(url) return wpage.text How to handle exceptions properly that can arise during execution of the requests.get(url)? If I call this function with try: html =

Re: No Content-Length header, nor length property

2015-07-09 Thread zljubisic
Ah - looking at the response headers, they include Transfer-Encoding chunked - I don't think urlopen handles chunked responses by default, though I could be wrong, I don't have time to check the docs right now. The requests library (https://pypi.python.org/pypi/requests) seems to handle

Re: No Content-Length header, nor length property

2015-07-08 Thread zljubisic
Hello, urlopen returns an HttpResponse object(https://docs.python.org/3/library/http.client.html#httpresponse-objects). You need to call read() on the return value to get the page content, or you could consider the getheader method to check for a Content- Length header. Hope that

No Content-Length header, nor length property

2015-07-07 Thread zljubisic
Hi, if I put the link in the browser, I will be offered to save the file to the local disk. If I execute these few lines of code, I will get None: import urllib.request url = 'http://radio.hrt.hr/prvi-program/aod/download/118467/' site = urllib.request.urlopen(url) print('File size:',

Re: Python 3 resuma a file download

2015-07-04 Thread zljubisic
I have a working solution. :) The function below will download a file securely. Thank anyone who helped. I wouldn't be able to write this function without your help. I hope, someone else will benefit from our united work. Best regards. import os import urllib.request def Download(rfile,

Re: Python 3 resuma a file download

2015-07-02 Thread zljubisic
This is my final version which doesn't work. :( Actually, it works with another file on another server, but doesn't work with mp4 files on this particular server. I really don't know what to do? Regards. import os import urllib.request def Download(rfile, lfile): retval = False if

Re: Python 3 resuma a file download

2015-07-01 Thread zljubisic
On Wednesday, 1 July 2015 01:43:19 UTC+2, Cameron Simpson wrote: On 30Jun2015 08:34, zljubi...@gmail.com zljubi...@gmail.com wrote: I would like to download a file (http://video.hrt.hr/2906/otv296.mp4) If the connection is OK, I can download the file with: import urllib.request

Re: Python 3 resuma a file download

2015-07-01 Thread zljubisic
New version with chunks: import os import urllib.request def Download(rfile, lfile): retval = False if os.path.isfile(lfile): lsize = os.stat(lfile).st_size else: lsize = 0 req = urllib.request.Request(rfile) req.add_header('Range', bytes={}-.format(lsize))

Re: Python 3 resuma a file download

2015-07-01 Thread zljubisic
But how to read chunks? -- https://mail.python.org/mailman/listinfo/python-list

Re: Python 3 resuma a file download

2015-07-01 Thread zljubisic
Currently I am executing the following code: import os import urllib.request def Download(rfile, lfile): retval = False if os.path.isfile(lfile): lsize = os.stat(lfile).st_size else: lsize = 0 req = urllib.request.Request(rfile) req.add_header('Range',

Python 3 resuma a file download

2015-06-30 Thread zljubisic
Hi, I would like to download a file (http://video.hrt.hr/2906/otv296.mp4) If the connection is OK, I can download the file with: import urllib.request urllib.request.urlretrieve(remote_file, local_file) Sometimes when I am connected on week wireless (not mine) network I get WinError 10054