I made a simple shell script that will create a virtualenv, activate it, install requirements.txt, run unittests, and then tear down the virtualenv. I setup a jenkins job to run this script, but it's not finding any tests: code:
|
|
# ? Sep 17, 2014 21:45 |
|
|
# ? May 9, 2024 02:12 |
|
I don't have an answer specifically for your question, but I'd like to note that there's a Jenkins virtualenv plugin that does all of the setup and dependency management for you.
|
# ? Sep 17, 2014 23:27 |
BeefofAges posted:I don't have an answer specifically for your question, but I'd like to note that there's a Jenkins virtualenv plugin that does all of the setup and dependency management for you. This one right? https://github.com/jenkinsci/shiningpanda-plugin The last couple plugins I have tried have been awful...I was hoping not to have to use a plugin unless absolutely necessary since the quality is just so hit and miss. What I'm trying to do seems like it would be really simple without having to use a plugin. edit: Plus it's be easy for other devs to run the job like jenkins is going to run it, since it's just a bash script that lives with the project in source control Have you used that shiningpanda one with success? fletcher fucked around with this message at 00:04 on Sep 18, 2014 |
|
# ? Sep 18, 2014 00:01 |
Figured it out. It was the PATH environment variable that Jenkins was using. It didn't have /usr/local/bin on it (where Python 2.7.8 is installed) so I think it was trying to use some older Python 2.6 in /usr/bin
|
|
# ? Sep 18, 2014 00:56 |
|
FoiledAgain posted:Question about pickles and bytes. I have the following code, which works. IOBase objects like BytesIO are iterated line by line. Python code:
I'm curious what you are doing here though, since this doesn't look like a method you would normally need to override. If you need to control the unpickling of objects, maybe you could use __setstate__() instead?
|
# ? Sep 18, 2014 01:37 |
|
I need some help. I'm trying to parse a simple webpage: http://www.nlm.nih.gov/medlineplus/abdominalpain.html There is a summary of abdominal pain that I want to grab and print to console. The summary is after the div tag: code:
code:
|
# ? Sep 18, 2014 03:04 |
|
HTMLParser might be more useful than doing that manually with a regex. Here's a very similar example. If you ever do need to work out a regex, Regex101 is very helpful.
|
# ? Sep 18, 2014 03:14 |
|
I've made progress with this:code:
|
# ? Sep 18, 2014 03:23 |
|
Just chiming in to echo that HTMLParser is amazing and you should use it. e: ^^ BeutifulSoup is also very nice, although they are quite different in the way you use them.
|
# ? Sep 18, 2014 03:24 |
|
Hughmoris posted:I've made progress with this: Does beautiful soup support xpath? Google xpath and read the tutorial on w3school or whatever that place is. If beautiful soup doesn't support it switch to lxml maybe?
|
# ? Sep 18, 2014 03:42 |
|
fletcher posted:This one right? https://github.com/jenkinsci/shiningpanda-plugin Yeah, that's the one I use. It works great.
|
# ? Sep 18, 2014 04:43 |
|
KICK BAMA KICK posted:HTMLParser might be more useful than doing that manually with a regex. Here's a very similar example. Thanks for these. Regex has always kicked my rear end but I've spent some effort trying to learn it now, and its still kicking my rear end. As a simple experiment, I'm trying to pull the zipcode from this page with this code: http://www.nlm.nih.gov/medlineplus/abdominalpain.html code:
Any ideas where I'm going wrong? *EDIT I modified the code and instead of using re.match(pattern, webpage) I use re.findall(pattern, webpage) and it works. Not sure I really understand the difference between re.match and re.findall Hughmoris fucked around with this message at 05:15 on Sep 18, 2014 |
# ? Sep 18, 2014 05:06 |
|
I'm having a strange issue rounding numbers in pandas and exporting to dict. my_series is the result of some aggregations on a dataframe with .astype('float') applied at the end. Unrounded: Python code:
Python code:
Python code:
to_csv(), to_records(), etc. results in the correct rounding. Only to_dict() poses a problem. Is this a bug? emoji fucked around with this message at 11:28 on Sep 18, 2014 |
# ? Sep 18, 2014 11:26 |
|
Another dumb newbie question. I'm trying to learn how to structure projects properly and I can't get my head around how to manipulate variables across modules. Let's say I have my main module, in which I have a list of objects I need to keep track of within the main program loop. Then in another module I have defined some functions that work on that list. code:
code:
Any good beginner tutorials on working with modules? The stuff I've read so far seems a bit too high-level for the kind of problems I'm encountering.
|
# ? Sep 18, 2014 13:25 |
|
See if this works:Python code:
Python code:
|
# ? Sep 18, 2014 14:22 |
|
grate deceiver posted:Another dumb newbie question. I'm trying to learn how to structure projects properly and I can't get my head around how to manipulate variables across modules. In general though if you have an object/function in a file named my_stuff.py and want to use in in another file called my_other_stuff.py then you must have "import my_stuff" in the file "my_other_stuff.py".
|
# ? Sep 18, 2014 14:24 |
|
Hughmoris posted:Thanks for these. Regex has always kicked my rear end but I've spent some effort trying to learn it now, and its still kicking my rear end. http://stackoverflow.com/a/1732454 You might find that interesting.
|
# ? Sep 18, 2014 14:28 |
|
Jose Cuervo posted:Is there a reason you are not passing the list of objects to the function as a parameter? Oh, right. Guess I just forgot in the confusion. However, this still doesn't work: Python code:
Python code:
HardDisk posted:However, it sounds to me that you should wrap the obj_list and the functions with a class. Yeah, the more I struggle with it, the more it looks like this might be the best approach.
|
# ? Sep 18, 2014 14:53 |
|
Python code:
Python code:
|
# ? Sep 18, 2014 15:06 |
|
Thermopyle posted:http://stackoverflow.com/a/1732454 I stumbled upon that a while back during my ill-fated attempt to learn Perl. I have it bookmarked. I was actually thinking about it last night while I was trying to parse HTML using RegEx. The <center> cannot hold it is too late. That being said, after much cussing and frustration, I was finally able to parse what I wanted using RegEx.
|
# ? Sep 18, 2014 15:08 |
|
grate deceiver posted:Oh, right. Guess I just forgot in the confusion. However, this still doesn't work: You don't have the name objects in your example code anywhere, so we can't troubleshoot your problem. You probably have a name you forgot to change somewhere. The best solution really depends on the specifics though. What are these objects representing? Constants? Some sort of global program state you want to be available in many places?
|
# ? Sep 18, 2014 15:42 |
|
Nevermind, I'm dumb. Turns out there's a ton of interdependencies all over the place that I need to untangle in order to move anything.
|
# ? Sep 18, 2014 15:47 |
|
SurgicalOntologist posted:I have an idea for a mini-project and I'd like to run it by here to see what people think, and if there's a better way to accomplish this. Wondering if anyone has a more "elegant" idea before I start implementing dynamic implementations of the nginx config.
|
# ? Sep 18, 2014 16:00 |
|
SurgicalOntologist posted:Wondering if anyone has a more "elegant" idea before I start implementing dynamic implementations of the nginx config. You could write a reverse proxy in Twisted pretty easily and give it whatever API you wanted.
|
# ? Sep 18, 2014 17:10 |
|
Thermopyle posted:http://stackoverflow.com/a/1732454 Came in to post this. Classic.
|
# ? Sep 18, 2014 17:17 |
|
Hughmoris posted:*EDIT To quote from the documentation: quote:Python offers two different primitive operations based on regular expressions: re.match() checks for a match only at the beginning of the string, while re.search() checks for a match anywhere in the string (this is what Perl does by default).
|
# ? Sep 18, 2014 17:22 |
|
This mostly a general design question. I'm trying to clean up some code about 100 lines of it is just me defining some parameters for several different webpages I make. Is it kosher for me to just pickle these presets?
|
# ? Sep 18, 2014 18:35 |
|
TheOtherContraGuy posted:This mostly a general design question. What's the purpose of pickling them? You're still going to have to have lines of code that define those parameters , more lines that pickle those parameters , and then you'll have to add lines of code to unpickle them. That's way messier than just putting your parameters into a separate .py and importing from it the specific parameters that you need
|
# ? Sep 18, 2014 18:48 |
|
QuarkJets posted:What's the purpose of pickling them? You're still going to have to have lines of code that define those parameters , more lines that pickle those parameters , and then you'll have to add lines of code to unpickle them. That's way messier than just putting your parameters into a separate .py and importing from it the specific parameters that you need Good point. I'll do that.
|
# ? Sep 18, 2014 18:51 |
|
Steampunk Hitler posted:You could write a reverse proxy in Twisted pretty easily and give it whatever API you wanted. It all seems like such overkill for what I thought would be a simple personal-use webapp.
|
# ? Sep 18, 2014 19:07 |
|
kraftwerk singles posted:I'm having a strange issue rounding numbers in pandas and exporting to dict. This appears to be working as intended. You told python you only cared about two decimal places and then complained when the 18th decimal place wasn't what you expected. Basically, when you call round on 0.081347309478284627, you're asking for a number that is indistinguishable from 0.08 within floating point precision. That is exactly what you got. The problem is, 0.08 cannot be specified exactly in binary just like 1/3 cannot be specified exactly in decimal. Try subtracting 0.08 from 0.080000000000000002, you should get 0 not 2E-12. If you want number represented exactly to two decimal places, use a decimal class.
|
# ? Sep 18, 2014 20:57 |
|
KernelSlanders posted:This appears to be working as intended. You told python you only cared about two decimal places and then complained when the 18th decimal place wasn't what you expected. Yea, I figured this out after some investigation. It still seems weird that the other export functions round to two decimal places. Keeping with the Decimal class made my manipulations a bit messier since I'm combining disparate data sources. I ended up using string formatting since it's for display purposes and I wanted to minimize the size of the json sent over the network.
|
# ? Sep 18, 2014 22:33 |
|
Hughmoris posted:Thanks for these. Regex has always kicked my rear end but I've spent some effort trying to learn it now, and its still kicking my rear end. Are you only parsing data from Medline Plus? If so, why not use the API that the NIH provides (http://www.nlm.nih.gov/api/). They have a free API for pretty much all of their services.
|
# ? Sep 19, 2014 04:27 |
|
I have a simple, 9-line python regex script that I wrote for work. Currently, it will read a text file and print out matches defined by the user. I'd like to get it to the point where it can iterate over the contents of a folder and find matches in each text file in that folder. I'd like my coworkers to be able to use this script. The problem is that none of them know anything about programming, and none of them have python installed on their systems. What would be an easy way to make this script available and easy to use for them? We have a shared network drive. I've read that there is a python-to-exe converter. How is that process? Since the script is so small, would it maybe be easier to write it in another language? Maybe in a language that uses web browser? I think our work computers are still rocking IE 8. Modern Pragmatist posted:Are you only parsing data from Medline Plus? If so, why not use the API that the NIH provides (http://www.nlm.nih.gov/api/). They have a free API for pretty much all of their services. I wasn't aware they had an API. Thank you for this. Hughmoris fucked around with this message at 14:54 on Sep 19, 2014 |
# ? Sep 19, 2014 14:28 |
|
Having a bit of a problem with py2exe and a short python script I've written. The script raises a warning under some circumstances, and depending on the command line the program may crash when that warning is issued. The weird part about it is that it's actually tied to how you specify the executable name. Calling "fbxtomdl.exe" with the .exe extension present will exhibit the bug, but just calling "fbxtomdl" without an extension prints the warning and works fine. The traceback is pre:Traceback (most recent call last): File "fbxtomdl.py", line 180, in <module> File "E:\Python33\lib\warnings.py", line 18, in showwarning file.write(formatwarning(message, category, filename, lineno, line)) File "E:\Python33\lib\warnings.py", line 25, in formatwarning line = linecache.getline(filename, lineno) if line is None else line File "E:\Python33\lib\linecache.py", line 15, in getline lines = getlines(filename, module_globals) File "E:\Python33\lib\linecache.py", line 41, in getlines return updatecache(filename, module_globals) File "E:\Python33\lib\linecache.py", line 126, in updatecache with tokenize.open(fullname) as fp: File "E:\Python33\lib\tokenize.py", line 438, in open encoding, lines = detect_encoding(buffer.readline) File "E:\Python33\lib\tokenize.py", line 416, in detect_encoding encoding = find_cookie(first) File "E:\Python33\lib\tokenize.py", line 380, in find_cookie raise SyntaxError(msg) SyntaxError: invalid or missing encoding declaration for '..\\..\\fbxtomdl\\fbxt omdl.exe' Code can be found at http://tomeofpreach.wordpress.com/qmdl/fbxtomdl/ if that helps.
|
# ? Sep 22, 2014 01:56 |
|
Hughmoris posted:I'd like my coworkers to be able to use this script. You could put a python runtime on the network share, then have a batch file which calls the script against that runtime. code:
David Pratt fucked around with this message at 16:03 on Sep 22, 2014 |
# ? Sep 22, 2014 16:00 |
|
I'm trying to figure out python syntax, and one of the codecademy exercises is to write a function that removes all duplicates of integers in a list, so if you have [1,1,2,2,3] it returns [1,2,3]. I first wrote:code:
code:
|
# ? Sep 22, 2014 16:18 |
|
The problem is that out.append(i) modifies out in-place and returns None. In a comprehension, you need to use the value itself. So you should try: Python code:
|
# ? Sep 22, 2014 16:33 |
|
SurgicalOntologist posted:The problem is that out.append(i) modifies out in-place and returns None. In a comprehension, you need to use the value itself. There's also the numpy.unique function.
|
# ? Sep 22, 2014 18:05 |
|
|
# ? May 9, 2024 02:12 |
|
David Pratt posted:You could put a python runtime on the network share, then have a batch file which calls the script against that runtime. Thanks for this. It is exactly what I'm looking for but I'm having a bit of a trouble to get working. I have a script called hello_world.py.I have Python installed on my laptop at C:\Python27\python.exe. I want to make the script accessible to my coworkers on the network drive I:\Public\Scripts. The batch file below does not appear to launch the script from the network drive: code:
What am I missing? Edit: Do I need to install Python to the network drive? Not sure if the IT guys will be a fan of that. Hughmoris fucked around with this message at 18:42 on Sep 22, 2014 |
# ? Sep 22, 2014 18:20 |