Search Results

Search found 19539 results on 782 pages for 'pretty print'.

Page 77/782 | < Previous Page | 73 74 75 76 77 78 79 80 81 82 83 84  | Next Page >

  • Network Printer Issue.

    - by goldenmean
    Hello, I have a Windows-7 Desktop at office. There is a network printer Dell MFP2335dn which is installed on this dekstop. The printer worked fine for me(I could print from my desktop), sometime back but recently i am not been able to print. When i give a print job, it stays in the queue for a long time, nothing gets printed. When i see the status of the printer in "Devices and Printers", it says - Offline. I removed the printer installed on my Desktop, and tried to install the drivers downloaded from Dell website: http://support.euro.dell.com/support/downloads/download.aspx?c=uk&l=en&s=gen&releaseid=R241894&formatcnt=0&libid=0&typeid=-1&dateid=-1&formatid=-1&source=-1&fileid=349205 But still the same problem. I don't know what to do more to resolve this. Any pointers about how to resolve this error and get printing done. thanks, -AD.

    Read the article

  • CentOS, CUPS - printer managment

    - by HTF
    I'm using CentOS 6.3, and trying to get a printer PIXMA iP4950 to work. The printer is attached via USB. I've downloaded and installed the drivers from the Cannon website, and have the printer installed in CUPS. However, when I print anything (even the test page), the job is completed successfully (according to CUPS-log), but the printer does not print a thing. I don't know how to debug this. Have tried to change logging to debug, but I don't see any errors in the error_log and the access_log says: Returning IPP successful-ok for Get-Jobs (ipp://localhost:631/printers/Canon_iP4900_series) from localhost Please note that I was able to print on another CentOS machine however with GNOME Desktop.

    Read the article

  • How to distill / rasterize a PDF in Linux

    - by Sampo
    We have a printer at our office that prints PDF files from a USB stick. It prints most files okay, but it has problems with some, especially ones generated with Latex. Some PDFs it simply refuses to print, some PDFs it prints with courier-type font, and some it prints fine except for equations. I'm looking for a way to "distill" PDFs into a dead-sure format to print. Either by simplifying / normalizing the PDF to the point that any renderer will render it correctly, or by simply making each page a 600dpi raster image in the PDF. (I could split the PDF into individual raster images and combine them manually, but I want something scriptable.) The output file size doesn't matter, as long as it's sure to print, has A4 paper size (or the original) and 300~600dpi resolution.

    Read the article

  • Recommendations: Good Network MFP Printer/Scanner

    - by Joeme
    Hi, We have a small office that is expanding. At the moment we have 1x HP J6424 MFP, shared using it's built in network port. It is now becoming a headache, we have daily problems with people not being able to print or scan, and jobs just sitting in the queue. Or the scanner not being detected. Sometimes people can print but not scan, sometimes scan but not print, sometimes a bit of both. We are also pretty much constantly printing or scanning, or trying to! I would like to get a laser MFP (mono is fine) which works well for scanning a printing over the network with multiple users. Althernativly any recommendations for network scanners (sheet feed and or duplex a bonus). Clients are Windows 7 and Mac. Thanks very much!

    Read the article

  • Dos-based printing from NT to unix/linux.

    - by SHW
    I need help for the below mentioned scenario: A Dot-matrix printer is physically connected to the Linux machine ( e.g. Ubuntu-10.04 , it can be any unix/linux flavour) From this linux machine, when I take a RDP to the Windows NT-4.0 TS, I run the DOS-based application. Now I want to print few pages from this DOS-based application to the Ubuntu's printer, When I am in RDP-Session. When I followed the samba-printing documentation, I am able to print from GUI-based apps like Notepad, MS WORD and so forth; but not able to print from the command prompt of Windows. Any idea how to do this ? [ WINDOWS MACHINE IS STRICTLY NT-4.0 2000 TS ]

    Read the article

  • windows printer spool gets stuck with file at 64kb from linux and mac

    - by Juan Diego
    Hi I have two printers one on a file server with windows 2003, and other with windows XP. The thing is that when i try to print from my machine, my file stays in queue for ever, it says 64kb out of whatever the file i send. I have seen similar problems with some machines that run on Mac OS X. The windows machines apparently have no problems printing. They are not connect through active directory, just the network. In the past I have seen people install non microsoft windows Printer server on windows, i dont remember the name of any of the programs. I have being googling a lot and have not found anything to replace the microsoft print spooler service, maybe i am mistaken. Everyday I have to restart the print spooler service i even created a bat file for it. I am out of ideas here.

    Read the article

  • TextPad printing to incorrect printer

    - by TecBrat
    I have tried to find an answer on Google, and searched SU, but have not found anything on this particular issue. I Looked for a setting in the TextPad menu and didn't see anything that seemed relevant. I have 2 networked printers that are the same model. (HP LaserJet 2200 Series PCL 5) One is near me and the other is across the building. The one near me is my default. It seems that TextPad remembers the last printer used and defaults to it rather than printing to the system default, so when I force it to print to my default printer once, the problem is solved until I decide to print to the other printer for some reason. If I don't remember the problem, and specifically print a job to the nearby printer to correct it, I'll end up either wasting paper or wasting trips across the building to pick up printjobs that got printed there by accident. Has anyone else noticed this problem? Is there a solution?

    Read the article

  • How Do I Enable CUPS Browsing Across A Network?

    - by David Mackintosh
    I have a CUPS server with two print queues defined. Once this was defined, all the CUPS clients on the same subnet could see the two print queues automatically, no problem. Now I have a collection of machines on a separate subnet, reachable from the first subnet by a router. How do I enable CUPS browsing on the second set of machines so that they can see the print queues defined on the first machine? Let's call the server A.B.C.7. The first subnet is A.B.C.0/24. The second subnet is A.B.D.0/24, and there is a router with arms on both networks.

    Read the article

  • small Windows network w/ printer issue

    - by user33666
    printer 1 connected to the desktop printer 2 connected to the same desktop that desktop is connected via Cat 5 to a wireless router a notebook is connected to that same router via WiFi The desktop Control Panel has just been reconfigured to share printers. (I assume this means that the desktop will now allow a notebook coming through the router to be able to access the two printers that are presently hooked up via the desktop--am I correct? Is that what it means?) The desktop can still print to either printer. It is presently okay. This notebook/printer relationship is a new configuration. The notebook, however, can't print at all (yet it can access the internet just fine). Any suggestions for it to be able to access the printers and be able to print via the desktop via the router? Thank you for any assistance.

    Read the article

  • "Access is denied" when copying text file to printer UNC path

    - by Patrick
    We have a new server running Server 2008 R2. We also have a "DOS-based" program that prints directly to the UNC path of a print share. With the new server, we are unable to print from this program. According to support, the program's printing works in the same way as if we were to do a "copy mytextfile.txt \\myserver\myprinter". When we try to run this command in DOS, we get "Access is denied". Support is saying that this is why the DOS program is not able to print. I have tried granting all permissions on the printer to the appropriate users (under Security of the printer properties) but that did not work. Is there a policy setting that would cause this to be denied?

    Read the article

  • Only show changed files with verbose option

    - by qox
    I would like rsync to print modified and deleted files. The verbose option (-v) does print modified files but also the list of subdirectories, maybe because touched directories are considered modified. Since I sync a lot of files from a lot of subdirectories, it's impossible to see the actual changes. So, is there a way to not print directories using rsync ? Im not looking for grep -v "*/$" kind of answers since it would also exclude new directories. Command I am using: rsync -avh --delete /media/data/src /media/data/bkp And everytime it prints the list of all directories: src/dir1/ src/dir1/sdir1/ src/dir1/sdir2/ src/dir2/ ..... Thanks for your help.

    Read the article

  • Temporarily block other users from network printer

    - by TecBrat
    I found where someone else asked this question here, but they did not get a working answer. We have a printer that is shared. It has it's own network card, so we all have equal access to it. (none of our computers owns it) One of our users needs to print on specialty paper and we need to be sure not to print when that paper is in the printer. Our current method is "Hey, don't print anything right now!" Obviously this method is not preferred because it does not enforce itself. :-) I think all our PCs are running Win7 Home. The printer in question is an HP Laserjet 2200. Is there a way that we can make this happen?

    Read the article

  • File filtering_Python 3.2 [closed]

    - by user71261
    I'm trying to write a short file filtering code in Python that will find my desired string. I've got it worked out logically, but my Command Feed is sending me an error message for the print statement. This is how it works as of now: filename = input('give file name: ') n = input('give desired string: ') f = open line = f.readline() while line: if n in line: print line line = f.readline() Error Statement: Traceback (most recent call last): File "<string>", line 7, in <fragment> Syntax Error: print line: <string>, line 718 I know this is a simple problem but the answer is not obvious to me. please help.

    Read the article

  • Building an interleaved buffer for pyopengl and numpy

    - by Nick Sonneveld
    I'm trying to batch up a bunch of vertices and texture coords in an interleaved array before sending it to pyOpengl's glInterleavedArrays/glDrawArrays. The only problem is that I'm unable to find a suitably fast enough way to append data into a numpy array. Is there a better way to do this? I would have thought it would be quicker to preallocate the array and then fill it with data but instead, generating a python list and converting it to a numpy array is "faster". Although 15ms for 4096 quads seems slow. I have included some example code and their timings. #!/usr/bin/python import timeit import numpy import ctypes import random USE_RANDOM=True USE_STATIC_BUFFER=True STATIC_BUFFER = numpy.empty(4096*20, dtype=numpy.float32) def render(i): # pretend these are different each time if USE_RANDOM: tex_left, tex_right, tex_top, tex_bottom = random.random(), random.random(), random.random(), random.random() left, right, top, bottom = random.random(), random.random(), random.random(), random.random() else: tex_left, tex_right, tex_top, tex_bottom = 0.0, 1.0, 1.0, 0.0 left, right, top, bottom = -1.0, 1.0, 1.0, -1.0 ibuffer = ( tex_left, tex_bottom, left, bottom, 0.0, # Lower left corner tex_right, tex_bottom, right, bottom, 0.0, # Lower right corner tex_right, tex_top, right, top, 0.0, # Upper right corner tex_left, tex_top, left, top, 0.0, # upper left ) return ibuffer # create python list.. convert to numpy array at end def create_array_1(): ibuffer = [] for x in xrange(4096): data = render(x) ibuffer += data ibuffer = numpy.array(ibuffer, dtype=numpy.float32) return ibuffer # numpy.array, placing individually by index def create_array_2(): if USE_STATIC_BUFFER: ibuffer = STATIC_BUFFER else: ibuffer = numpy.empty(4096*20, dtype=numpy.float32) index = 0 for x in xrange(4096): data = render(x) for v in data: ibuffer[index] = v index += 1 return ibuffer # using slicing def create_array_3(): if USE_STATIC_BUFFER: ibuffer = STATIC_BUFFER else: ibuffer = numpy.empty(4096*20, dtype=numpy.float32) index = 0 for x in xrange(4096): data = render(x) ibuffer[index:index+20] = data index += 20 return ibuffer # using numpy.concat on a list of ibuffers def create_array_4(): ibuffer_concat = [] for x in xrange(4096): data = render(x) # converting makes a diff! data = numpy.array(data, dtype=numpy.float32) ibuffer_concat.append(data) return numpy.concatenate(ibuffer_concat) # using numpy array.put def create_array_5(): if USE_STATIC_BUFFER: ibuffer = STATIC_BUFFER else: ibuffer = numpy.empty(4096*20, dtype=numpy.float32) index = 0 for x in xrange(4096): data = render(x) ibuffer.put( xrange(index, index+20), data) index += 20 return ibuffer # using ctype array CTYPES_ARRAY = ctypes.c_float*(4096*20) def create_array_6(): ibuffer = [] for x in xrange(4096): data = render(x) ibuffer += data ibuffer = CTYPES_ARRAY(*ibuffer) return ibuffer def equals(a, b): for i,v in enumerate(a): if b[i] != v: return False return True if __name__ == "__main__": number = 100 # if random, don't try and compare arrays if not USE_RANDOM and not USE_STATIC_BUFFER: a = create_array_1() assert equals( a, create_array_2() ) assert equals( a, create_array_3() ) assert equals( a, create_array_4() ) assert equals( a, create_array_5() ) assert equals( a, create_array_6() ) t = timeit.Timer( "testing2.create_array_1()", "import testing2" ) print 'from list:', t.timeit(number)/number*1000.0, 'ms' t = timeit.Timer( "testing2.create_array_2()", "import testing2" ) print 'array: indexed:', t.timeit(number)/number*1000.0, 'ms' t = timeit.Timer( "testing2.create_array_3()", "import testing2" ) print 'array: slicing:', t.timeit(number)/number*1000.0, 'ms' t = timeit.Timer( "testing2.create_array_4()", "import testing2" ) print 'array: concat:', t.timeit(number)/number*1000.0, 'ms' t = timeit.Timer( "testing2.create_array_5()", "import testing2" ) print 'array: put:', t.timeit(number)/number*1000.0, 'ms' t = timeit.Timer( "testing2.create_array_6()", "import testing2" ) print 'ctypes float array:', t.timeit(number)/number*1000.0, 'ms' Timings using random numbers: $ python testing2.py from list: 15.0486779213 ms array: indexed: 24.8184704781 ms array: slicing: 50.2214789391 ms array: concat: 44.1691994667 ms array: put: 73.5879898071 ms ctypes float array: 20.6674289703 ms edit note: changed code to produce random numbers for each render to reduce object reuse and to simulate different vertices each time. edit note2: added static buffer and force all numpy.empty() to use dtype=float32 note 1/Apr/2010: still no progress and I don't really feel that any of the answers have solved the problem yet.

    Read the article

  • Perl - WWW::Mechanize Cookie Session Id is being reset with every get(), how to make it stop?

    - by Phill Pafford
    So I'm scraping a site that I have access to via HTTPS, I can login and start the process but each time I hit a new page (URL) the cookie Session Id changes. How do I keep the logged in Cookie Session Id? #!/usr/bin/perl -w use strict; use warnings; use WWW::Mechanize; use HTTP::Cookies; use LWP::Debug qw(+); use HTTP::Request; use LWP::UserAgent; use HTTP::Request::Common; my $un = 'username'; my $pw = 'password'; my $url = 'https://subdomain.url.com/index.do'; my $agent = WWW::Mechanize->new(cookie_jar => {}, autocheck => 0); $agent->{onerror}=\&WWW::Mechanize::_warn; $agent->agent('Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.3) Gecko/20100407 Ubuntu/9.10 (karmic) Firefox/3.6.3'); $agent->get($url); $agent->form_name('form'); $agent->field(username => $un); $agent->field(password => $pw); $agent->click("Log In"); print "After Login Cookie: "; print $agent->cookie_jar->as_string(); print "\n\n"; my $searchURL='https://subdomain.url.com/search.do'; $agent->get($searchURL); print "After Search Cookie: "; print $agent->cookie_jar->as_string(); print "\n"; The output: After Login Cookie: Set-Cookie3: JSESSIONID=367C6D; path="/thepath"; domain=subdomina.url.com; path_spec; secure; discard; version=0 After Search Cookie: Set-Cookie3: JSESSIONID=855402; path="/thepath"; domain=subdomain.com.com; path_spec; secure; discard; version=0 Also I think the site requires a CERT (Well in the browser it does), would this be the correct way to add it? $ENV{HTTPS_CERT_FILE} = 'SUBDOMAIN.URL.COM'; ## Insert this after the use HTTP::Request... Also for the CERT In using the first option in this list, is this correct? X.509 Certificate (PEM) X.509 Certificate with chain (PEM) X.509 Certificate (DER) X.509 Certificate (PKCS#7) X.509 Certificate with chain (PKCS#7)

    Read the article

  • boolean in java: what am I doing wrong?

    - by Cheesegraterr
    Hello, I am trying to make my boolean value work. I am new at programming java so I must be missing something simple. I am trying to make it so that if one of the tire pressures is below 35 or over 45 the system outputs "bad inflation" For class me must use a boolean which is what I tried. I cant figure out why this isnt working. No matter what I do the boolean is always true. Any tips? public class tirePressure { private static double getDoubleSystem1 () //Private routine to simply read a double in from the command line { String myInput1 = null; //Store the string that is read form the command line double numInput1 = 0; //Used to store the converted string into an double BufferedReader mySystem; //Buffer to store input mySystem = new BufferedReader (new InputStreamReader (System.in)); // creates a connection to system files or cmd try { myInput1 = mySystem.readLine (); //reads in data from console myInput1 = myInput1.trim (); //trim command cuts off unneccesary inputs } catch (IOException e) //checks for errors { System.out.println ("IOException: " + e); return -1; } numInput1 = Double.parseDouble (myInput1); //converts the string to an double return numInput1; //return double value to main program } static public void main (String[] args) { double TireFR; //double to store input from console double TireFL; double TireBR; double TireBL; boolean goodPressure; goodPressure = false; System.out.println ("Tire Pressure Checker"); System.out.println (" "); System.out.print ("Enter pressure of front left tire:"); TireFL = getDoubleSystem1 (); //read in an double from the user if (TireFL < 35 || TireFL > 45) { System.out.println ("Pressure out of range"); goodPressure = false; } System.out.print ("Enter pressure of front right tire:"); TireFR = getDoubleSystem1 (); //read in an double from the user if (TireFR < 35 || TireFR > 45) { System.out.println ("Pressure out of range"); goodPressure = false; } if (TireFL == TireFR) System.out.print (" "); else System.out.println ("Front tire pressures do not match"); System.out.println (" "); System.out.print ("Enter pressure of back left tire:"); TireBL = getDoubleSystem1 (); //read in an double from the user if (TireBL < 35 || TireBL > 45) { System.out.println ("Pressure out of range"); goodPressure = false; } System.out.print ("Enter pressure of back right tire:"); TireBR = getDoubleSystem1 (); //read in an double from the user if (TireBR < 35 || TireBR > 45) { System.out.println ("Pressure out of range"); goodPressure = false; } if (TireBL == TireBR) System.out.print (" "); else System.out.println ("Back tire pressures do not match"); if (goodPressure = true) System.out.println ("Inflation is OK."); else System.out.println ("Inflation is BAD."); System.out.println (goodPressure); } //mainmethod } // tirePressure Class

    Read the article

  • storing a sorted array of hashes

    - by srk
    use strict; use warnings; my @aoh =( { 3 => 15, 4 => 8, 5 => 9, }, { 3 => 11, 4 => 25, 5 => 6, }, { 3 => 5, 4 => 18, 5 => 5, }, { 0 => 16, 1 => 11, 2 => 7, }, { 0 => 21, 1 => 13, 2 => 31, }, { 0 => 11, 1 => 14, 2 => 31, }, ); #declaring a new array to store the sorted hashes my @new; print "\n-------------expected output------------\n"; foreach my $href (@aoh) { #i want a new array of hashes where the hashes are sorted my %newhash; my @sorted_keys = sort {$href->{$b} <=> $href->{$a} || $b <=> $a} keys %$href; foreach my $key (@sorted_keys) { print "$key => $href->{$key}\n"; $newhash{$key} = $href->{$key}; } print "\n"; push(@new,\%newhash); } print "-----------output i am getting---------------\n"; foreach my $ref(@new) { my @skeys = sort {$ref->{$a} <=> $ref->{$b} } keys %$ref; foreach my $key (@skeys) { print "$key => $ref->{$key}\n" } print "\n"; } The output of the program : -------------expected output------------ 3 => 15 5 => 9 4 => 8 4 => 25 3 => 11 5 => 6 4 => 18 5 => 5 3 => 5 0 => 16 1 => 11 2 => 7 2 => 31 0 => 21 1 => 13 2 => 31 1 => 14 0 => 11 -----------output i am getting--------------- 4 => 8 5 => 9 3 => 15 5 => 6 3 => 11 4 => 25 3 => 5 5 => 5 4 => 18 2 => 7 1 => 11 0 => 16 1 => 13 0 => 21 2 => 31 0 => 11 1 => 14 2 => 31 Please tell me what am i doing wrong in storing the hashes into a new array.. how do i achieve what i want.. ? Thanks in advance...

    Read the article

  • How can I keep a hash sorted?

    - by srk
    use strict; use warnings; my @aoh =( { 3 => 15, 4 => 8, 5 => 9, }, { 3 => 11, 4 => 25, 5 => 6, }, { 3 => 5, 4 => 18, 5 => 5, }, { 0 => 16, 1 => 11, 2 => 7, }, { 0 => 21, 1 => 13, 2 => 31, }, { 0 => 11, 1 => 14, 2 => 31, }, ); #declaring a new array to store the sorted hashes my @new; print "\n-------------expected output------------\n"; foreach my $href (@aoh) { #i want a new array of hashes where the hashes are sorted my %newhash; my @sorted_keys = sort {$href->{$b} <=> $href->{$a} || $b <=> $a} keys %$href; foreach my $key (@sorted_keys) { print "$key => $href->{$key}\n"; $newhash{$key} = $href->{$key}; } print "\n"; push(@new,\%newhash); } print "-----------output i am getting---------------\n"; foreach my $ref(@new) { my @skeys = skeys %$ref; foreach my $key (@skeys) { print "$key => $ref->{$key}\n" } print "\n"; } The output of the program : -------------expected output------------ 3 => 15 5 => 9 4 => 8 4 => 25 3 => 11 5 => 6 4 => 18 5 => 5 3 => 5 0 => 16 1 => 11 2 => 7 2 => 31 0 => 21 1 => 13 2 => 31 1 => 14 0 => 11 -----------output i am getting--------------- 4 => 8 3 => 15 5 => 9 4 => 25 3 => 11 5 => 6 4 => 18 3 => 5 5 => 5 1 => 11 0 => 16 2 => 7 1 => 13 0 => 21 2 => 31 1 => 14 0 => 11 2 => 31 Please tell me what am i doing wrong in storing the hashes into a new array.. how do i achieve what i want.. ? Thanks in advance...

    Read the article

  • Python dictionary key missing

    - by Greg K
    I thought I'd put together a quick script to consolidate the CSS rules I have distributed across multiple CSS files, then I can minify it. I'm new to Python but figured this would be a good exercise to try a new language. My main loop isn't parsing the CSS as I thought it would. I populate a list with selectors parsed from the CSS files to return the CSS rules in order. Later in the script, the list contains an element that is not found in the dictionary. for line in self.file.readlines(): if self.hasSelector(line): selector = self.getSelector(line) if selector not in self.order: self.order.append(selector) elif selector and self.hasProperty(line): # rules.setdefault(selector,[]).append(self.getProperty(line)) property = self.getProperty(line) properties = [] if selector not in rules else rules[selector] if property not in properties: properties.append(property) rules[selector] = properties # print "%s :: %s" % (selector, "".join(rules[selector])) return rules Error encountered: $ css-combine combined.css test1.css test2.css Traceback (most recent call last): File "css-combine", line 108, in <module> c.run(outfile, stylesheets) File "css-combine", line 64, in run [(selector, rules[selector]) for selector in parser.order], KeyError: 'p' Swap the inputs: $ css-combine combined.css test2.css test1.css Traceback (most recent call last): File "css-combine", line 108, in <module> c.run(outfile, stylesheets) File "css-combine", line 64, in run [(selector, rules[selector]) for selector in parser.order], KeyError: '#header_.title' I've done some quirky things in the code like sub spaces for underscores in dictionary key names in case it was an issue - maybe this is a benign precaution? Depending on the order of the inputs, a different key cannot be found in the dictionary. The script: #!/usr/bin/env python import optparse import re class CssParser: def __init__(self): self.file = False self.order = [] # store rules assignment order def parse(self, rules = {}): if self.file == False: raise IOError("No file to parse") selector = False for line in self.file.readlines(): if self.hasSelector(line): selector = self.getSelector(line) if selector not in self.order: self.order.append(selector) elif selector and self.hasProperty(line): # rules.setdefault(selector,[]).append(self.getProperty(line)) property = self.getProperty(line) properties = [] if selector not in rules else rules[selector] if property not in properties: properties.append(property) rules[selector] = properties # print "%s :: %s" % (selector, "".join(rules[selector])) return rules def hasSelector(self, line): return True if re.search("^([#a-z,\.:\s]+){", line) else False def getSelector(self, line): s = re.search("^([#a-z,:\.\s]+){", line).group(1) return "_".join(s.strip().split()) def hasProperty(self, line): return True if re.search("^\s?[a-z-]+:[^;]+;", line) else False def getProperty(self, line): return re.search("([a-z-]+:[^;]+;)", line).group(1) class Consolidator: """Class to consolidate CSS rule attributes""" def run(self, outfile, files): parser = CssParser() rules = {} for file in files: try: parser.file = open(file) rules = parser.parse(rules) except IOError: print "Cannot read file: " + file finally: parser.file.close() self.serialize( [(selector, rules[selector]) for selector in parser.order], outfile ) def serialize(self, rules, outfile): try: f = open(outfile, "w") for rule in rules: f.write( "%s {\n\t%s\n}\n\n" % ( " ".join(rule[0].split("_")), "\n\t".join(rule[1]) ) ) except IOError: print "Cannot write output to: " + outfile finally: f.close() def init(): op = optparse.OptionParser( usage="Usage: %prog [options] <output file> <stylesheet1> " + "<stylesheet2> ... <stylesheetN>", description="Combine CSS rules spread across multiple " + "stylesheets into a single file" ) opts, args = op.parse_args() if len(args) < 3: if len(args) == 1: print "Error: No input files specified.\n" elif len(args) == 2: print "Error: One input file specified, nothing to combine.\n" op.print_help(); exit(-1) return [opts, args] if __name__ == '__main__': opts, args = init() outfile, stylesheets = [args[0], args[1:]] c = Consolidator() c.run(outfile, stylesheets) Test CSS file 1: body { background-color: #e7e7e7; } p { margin: 1em 0em; } File 2: body { font-size: 16px; } #header .title { font-family: Tahoma, Geneva, sans-serif; font-size: 1.9em; } #header .title a, #header .title a:hover { color: #f5f5f5; border-bottom: none; text-shadow: 2px 2px 3px rgba(0, 0, 0, 1); } Thanks in advance.

    Read the article

  • Error data: line 2 column 1 when using pycurl with gzip stream

    - by Sagar Hatekar
    Thanks for reading. Background: I am trying to read a streaming API feed that returns data in JSON format, and then storing this data to a pymongo collection. The streaming API requires a "Accept-Encoding" : "Gzip" header. What's happening: Code fails on json.loads and outputs - Extra data: line 2 column 1 - line 4 column 1 (char 1891 - 5597) (Refer Error Log below) This does NOT happen while parsing every JSON object - it happens at random. My guess is I am encountering some weird JSON object after every "x" proper JSON objects. I did reference how to use pycurl if requested data is sometimes gzipped, sometimes not? and Encoding error while deserializing a json object from Google but so far have been unsuccessful at resolving this error. Could someone please help me out here? Error Log: Note: The raw dump of the JSON object below is basically using the repr() method. '{"id":"tag:search.twitter.com,2005:207958320747782146","objectType":"activity","actor":{"objectType":"person","id":"id:twitter.com:493653150","link":"http://www.twitter.com/Deathnews_7_24","displayName":"Death News 7/24","postedTime":"2012-02-16T01:30:12.000Z","image":"http://a0.twimg.com/profile_images/1834408513/deathnewstwittersquare_normal.jpg","summary":"Crashes, Murders, Suicides, Accidents, Crime and Naturals Death News From All Around World","links":[{"href":"http://www.facebook.com/DeathNews724","rel":"me"}],"friendsCount":56,"followersCount":14,"listedCount":1,"statusesCount":1029,"twitterTimeZone":null,"utcOffset":null,"preferredUsername":"Deathnews_7_24","languages":["tr"]},"verb":"post","postedTime":"2012-05-30T22:15:02.000Z","generator":{"displayName":"web","link":"http://twitter.com"},"provider":{"objectType":"service","displayName":"Twitter","link":"http://www.twitter.com"},"link":"http://twitter.com/Deathnews_7_24/statuses/207958320747782146","body":"Kathi Kamen Goldmark, Writers\xe2\x80\x99 Catalyst, Dies at 63 http://t.co/WBsNlNtA","object":{"objectType":"note","id":"object:search.twitter.com,2005:207958320747782146","summary":"Kathi Kamen Goldmark, Writers\xe2\x80\x99 Catalyst, Dies at 63 http://t.co/WBsNlNtA","link":"http://twitter.com/Deathnews_7_24/statuses/207958320747782146","postedTime":"2012-05-30T22:15:02.000Z"},"twitter_entities":{"urls":[{"display_url":"nytimes.com/2012/05/30/boo\xe2\x80\xa6","indices":[52,72],"expanded_url":"http://www.nytimes.com/2012/05/30/books/kathi-kamen-goldmark-writers-catalyst-dies-at-63.html","url":"http://t.co/WBsNlNtA"}],"hashtags":[],"user_mentions":[]},"gnip":{"language":{"value":"en"},"matching_rules":[{"value":"url_contains: nytimes.com","tag":null}],"klout_score":11,"urls":[{"url":"http://t.co/WBsNlNtA","expanded_url":"http://www.nytimes.com/2012/05/30/books/kathi-kamen-goldmark-writers-catalyst-dies-at-63.html?_r=1"}]}}\r\n{"id":"tag:search.twitter.com,2005:207958321003638785","objectType":"activity","actor":{"objectType":"person","id":"id:twitter.com:178760897","link":"http://www.twitter.com/Mobanu","displayName":"Donald Ochs","postedTime":"2010-08-15T16:33:56.000Z","image":"http://a0.twimg.com/profile_images/1493224811/small_mobany_Logo_normal.jpg","summary":"","links":[{"href":"http://www.mobanuweightloss.com","rel":"me"}],"friendsCount":10272,"followersCount":9698,"listedCount":30,"statusesCount":725,"twitterTimeZone":"Mountain Time (US & Canada)","utcOffset":"-25200","preferredUsername":"Mobanu","languages":["en"],"location":{"objectType":"place","displayName":"Crested Butte, Colorado"}},"verb":"post","postedTime":"2012-05-30T22:15:02.000Z","generator":{"displayName":"twitterfeed","link":"http://twitterfeed.com"},"provider":{"objectType":"service","displayName":"Twitter","link":"http://www.twitter.com"},"link":"http://twitter.com/Mobanu/statuses/207958321003638785","body":"Mobanu: Can Exercise Be Bad for You?: Researchers have found evidence that some people who exercise do worse on ... http://t.co/mTsQlNQO","object":{"objectType":"note","id":"object:search.twitter.com,2005:207958321003638785","summary":"Mobanu: Can Exercise Be Bad for You?: Researchers have found evidence that some people who exercise do worse on ... http://t.co/mTsQlNQO","link":"http://twitter.com/Mobanu/statuses/207958321003638785","postedTime":"2012-05-30T22:15:02.000Z"},"twitter_entities":{"urls":[{"display_url":"nyti.ms/KUmmMa","indices":[116,136],"expanded_url":"http://nyti.ms/KUmmMa","url":"http://t.co/mTsQlNQO"}],"hashtags":[],"user_mentions":[]},"gnip":{"language":{"value":"en"},"matching_rules":[{"value":"url_contains: nytimes.com","tag":null}],"klout_score":12,"urls":[{"url":"http://t.co/mTsQlNQO","expanded_url":"http://well.blogs.nytimes.com/2012/05/30/can-exercise-be-bad-for-you/?utm_medium=twitter&utm_source=twitterfeed"}]}}\r\n' json exception: Extra data: line 2 column 1 - line 4 column 1 (char 1891 - 5597) Header Output: HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Vary: Accept-Encoding Date: Wed, 30 May 2012 22:14:48 UTC Connection: close Transfer-Encoding: chunked Content-Encoding: gzip get_stream.py: #!/usr/bin/env python import sys import pycurl import json import pymongo STREAM_URL = "https://stream.test.com:443/accounts/publishers/twitter/streams/track/Dev.json" AUTH = "userid:passwd" DB_HOST = "127.0.0.1" DB_NAME = "stream_test" class StreamReader: def __init__(self): try: self.count = 0 self.buff = "" self.mongo = pymongo.Connection(DB_HOST) self.db = self.mongo[DB_NAME] self.raw_tweets = self.db["raw_tweets_gnip"] self.conn = pycurl.Curl() self.conn.setopt(pycurl.ENCODING, 'gzip') self.conn.setopt(pycurl.URL, STREAM_URL) self.conn.setopt(pycurl.USERPWD, AUTH) self.conn.setopt(pycurl.WRITEFUNCTION, self.on_receive) self.conn.setopt(pycurl.HEADERFUNCTION, self.header_rcvd) while True: self.conn.perform() except Exception as ex: print "error ocurred : %s" % str(ex) def header_rcvd(self, header_data): print header_data def on_receive(self, data): temp_data = data self.buff += data if data.endswith("\r\n") and self.buff.strip(): try: tweet = json.loads(self.buff, encoding = 'UTF-8') self.buff = "" if tweet: try: self.raw_tweets.insert(tweet) except Exception as insert_ex: print "Error inserting tweet: %s" % str(insert_ex) self.count += 1 if self.count % 10 == 0: print "inserted "+str(self.count)+" tweets" except Exception as json_ex: print "json exception: %s" % str(json_ex) print repr(temp_data) stream = StreamReader()

    Read the article

  • Why am I getting a new session ID on every page fetch in my Perl WWW::Mechanize script?

    - by Phill Pafford
    So I'm scraping a site that I have access to via HTTPS, I can login and start the process but each time I hit a new page (URL) the cookie Session Id changes. How do I keep the logged in Cookie Session Id? #!/usr/bin/perl -w use strict; use warnings; use WWW::Mechanize; use HTTP::Cookies; use LWP::Debug qw(+); use HTTP::Request; use LWP::UserAgent; use HTTP::Request::Common; my $un = 'username'; my $pw = 'password'; my $url = 'https://subdomain.url.com/index.do'; my $agent = WWW::Mechanize->new(cookie_jar => {}, autocheck => 0); $agent->{onerror}=\&WWW::Mechanize::_warn; $agent->agent('Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.3) Gecko/20100407 Ubuntu/9.10 (karmic) Firefox/3.6.3'); $agent->get($url); $agent->form_name('form'); $agent->field(username => $un); $agent->field(password => $pw); $agent->click("Log In"); print "After Login Cookie: "; print $agent->cookie_jar->as_string(); print "\n\n"; my $searchURL='https://subdomain.url.com/search.do'; $agent->get($searchURL); print "After Search Cookie: "; print $agent->cookie_jar->as_string(); print "\n"; The output: After Login Cookie: Set-Cookie3: JSESSIONID=367C6D; path="/thepath"; domain=subdomina.url.com; path_spec; secure; discard; version=0 After Search Cookie: Set-Cookie3: JSESSIONID=855402; path="/thepath"; domain=subdomain.com.com; path_spec; secure; discard; version=0 Also I think the site requires a CERT (Well in the browser it does), would this be the correct way to add it? $ENV{HTTPS_CERT_FILE} = 'SUBDOMAIN.URL.COM'; ## Insert this after the use HTTP::Request... Also for the CERT In using the first option in this list, is this correct? X.509 Certificate (PEM) X.509 Certificate with chain (PEM) X.509 Certificate (DER) X.509 Certificate (PKCS#7) X.509 Certificate with chain (PKCS#7)

    Read the article

  • Constructor ambiguous quesiton

    - by Crystal
    I'm trying to create a simple date class, but I get an error on my main file that says, "call of overloaded Date() is ambiguous." I'm not sure why since I thought as long as I had different parameters for my constructor, I was ok. Here is my code: header file: #ifndef DATE_H #define DATE_H using std::string; class Date { public: static const int monthsPerYear = 12; // num of months in a yr Date(int = 1, int = 1, int = 1900); // default constructor Date(); // uses system time to create object void print() const; // print date in month/day/year format ~Date(); // provided to confirm destruction order string getMonth(int month) const; // gets month in text format private: int month; // 1 - 12 int day; // 1 - 31 int year; // any year int checkDay(int) const; }; #endif .cpp file #include <iostream> #include <iomanip> #include <string> #include <ctime> #include "Date.h" using namespace std; Date::Date() { time_t seconds = time(NULL); struct tm* t = localtime(&seconds); month = t->tm_mon; day = t->tm_mday; year = t->tm_year; } Date::Date(int mn, int dy, int yr) { if (mn > 0 && mn <= monthsPerYear) month = mn; else { month = 1; // invalid month set to 1 cout << "Invalid month (" << mn << ") set to 1.\n"; } year = yr; // could validate yr day = checkDay(dy); // validate the day // output Date object to show when its constructor is called cout << "Date object constructor for date "; print(); cout << endl; } void Date::print() const { string str; cout << month << '/' << day << '/' << year << '\n'; // new code for HW2 cout << setfill('0') << setw(3) << day; // prints in ddd cout << " " << year << '\n'; // yyyy format str = getMonth(month); // prints in month (full word), day, year cout << str << " " << day << ", " << year << '\n'; } and my main.cpp #include <iostream> #include "Date.h" using std::cout; int main() { Date date1(4, 30, 1980); date1.print(); cout << '\n'; Date date2; date2.print(); }

    Read the article

  • How can I disable 'output escaping' in minidom

    - by William
    I'm trying to build an xml document from scratch using xml.dom.minidom. Everything was going well until I tried to make a text node with a ® (Registered Trademark) symbol in. My objective is for when I finally hit print mydoc.toxml() this particular node will actually contain a ® symbol. First I tried: import xml.dom.minidom as mdom data = '®' which gives the rather obvious error of: File "C:\src\python\HTMLGen\test2.py", line 3 SyntaxError: Non-ASCII character '\xae' in file C:\src\python\HTMLGen\test2.py on line 3, but no encoding declared; see http://www.python.or g/peps/pep-0263.html for details I have of course also tried changing the encoding of my python script to 'utf-8' using the opening line comment method, but this didn't help. So I thought import xml.dom.minidom as mdom data = '&#174;' #Both accepted xml encodings for registered trademark data = '&reg;' text = mdom.Text() text.data = data print data print text.toxml() But because when I print text.toxml(), the ampersands are being escaped, I get this output: &reg; &amp;reg; My question is, does anybody know of a way that I can force the ampersands not to be escaped in the output, so that I can have my special character reference carry through to the XML document? Basically, for this node, I want print text.toxml() to produce output of &reg; or &#174; in a happy and cooperative way! EDIT 1: By the way, if minidom actually doesn't have this capacity, I am perfectly happy using another module that you can recommend which does. EDIT 2: As Hugh suggested, I tried using data = u'®' (while also using data # -*- coding: utf-8 -*- Python source tags). This almost helped in the sense that it actually caused the ® symbol itself to be outputted to my xml. This is actually not the result I am looking for. As you may have guessed by now (and perhaps I should have specified earlier) this xml document happens to be an HTML page, which needs to work in a browser. So having ® in the document ends up causing rubbish in the browser (® to be precise!). I also tried: data = unichr(174) text.data = data.encode('ascii','xmlcharrefreplace') print text.toxml() But of course this lead to the same origional problem where all that happens is the ampersand gets escaped by .toxml(). My ideal scenario would be some way of escaping the ampersand so that the XML printing function won't "escape" it on my behalf for the document (in other words, achieving my original goal of having &reg; or &#174; appear in the document). Seems like soon I'm going to have to resort to regular expressions! EDIT 2a: Or perhaps not. Seems like getting my html meta information correct <META http-equiv="Content-Type" Content="text/html; charset=UTF-8"> could help, but I'm not sure yet how this fits in with the xml structure...

    Read the article

  • Arduino Ethernet Shield Not Connecting to WebServer

    - by new user
    I have a problem making my Arduino Ethernet shield to communicate with the server, the result on the serial monitor is always: my arduino code is #include <Ethernet.h> //library for ethernet functions #include <SPI.h> #include <Dns.h> #include <Client.h> //library for client functions #include <DallasTemperature.h> //library for temperature sensors // Ethernet settings byte mac[] = {0x09,0xA2,0xDA,0x00,0x01,0x26}; //Replace with your Ethernet shield MAC byte ip[] = { 192,168,0,54}; //The Arduino device IP address byte subnet[] = { 255,255,255,0}; byte gateway[] = { 192,168,0,1}; IPAddress server(192,168,0,53); // IP-adress of server arduino sends data to EthernetClient client; bool connected = false; void setup(void) { Serial.begin(9600); Serial.println("Initializing Ethernet."); delay(1000); Ethernet.begin(mac, ip , gateway , subnet); } void loop(void) { if(!connected) { Serial.println("Not connected"); if (client.connect(server, 80)) { connected = true; int temp =analogRead(A1); Serial.print("Temp is "); Serial.println(temp); Serial.println(); Serial.println("Sending to Server: "); client.print("GET /formSubmit.php?t0="); Serial.print("GET /formSubmit.php?t0="); client.print(temp); Serial.print(temp); client.println(" HTTP/1.1"); Serial.println(" HTTP/1.1"); client.println("Host: http://localhost/PhpProject1/"); Serial.println("Host: http://localhost/PhpProject1/"); client.println("User-Agent: Arduino"); Serial.println("User-Agent: Arduino"); client.println("Accept: text/html"); Serial.println("Accept: text/html"); //client.println("Connection: close"); //Serial.println("Connection: close"); client.println(); Serial.println(); delay(10000); } else{ Serial.println("Cannot connect to Server"); } } else { delay(1000); while (client.connected() && client.available()) { char c = client.read(); Serial.print(c); } Serial.println(); client.stop(); connected = false; } } the server is an Apache server running on a pc, the server ip address in the code is the pc ip address. For testing purposes I work at my homes network, there's no proxy or firewall, and I also turned of the antivirus and firewall on my pc. the result in the serial monitor is always: Not connected Cannot connect to Server Any thoughts??

    Read the article

  • Ambiguous constructor call

    - by Crystal
    I'm trying to create a simple date class, but I get an error on my main file that says, "call of overloaded Date() is ambiguous." I'm not sure why since I thought as long as I had different parameters for my constructor, I was ok. Here is my code: header file: #ifndef DATE_H #define DATE_H using std::string; class Date { public: static const int monthsPerYear = 12; // num of months in a yr Date(int = 1, int = 1, int = 1900); // default constructor Date(); // uses system time to create object void print() const; // print date in month/day/year format ~Date(); // provided to confirm destruction order string getMonth(int month) const; // gets month in text format private: int month; // 1 - 12 int day; // 1 - 31 int year; // any year int checkDay(int) const; }; #endif .cpp file #include <iostream> #include <iomanip> #include <string> #include <ctime> #include "Date.h" using namespace std; Date::Date() { time_t seconds = time(NULL); struct tm* t = localtime(&seconds); month = t->tm_mon; day = t->tm_mday; year = t->tm_year; } Date::Date(int mn, int dy, int yr) { if (mn > 0 && mn <= monthsPerYear) month = mn; else { month = 1; // invalid month set to 1 cout << "Invalid month (" << mn << ") set to 1.\n"; } year = yr; // could validate yr day = checkDay(dy); // validate the day // output Date object to show when its constructor is called cout << "Date object constructor for date "; print(); cout << endl; } void Date::print() const { string str; cout << month << '/' << day << '/' << year << '\n'; // new code for HW2 cout << setfill('0') << setw(3) << day; // prints in ddd cout << " " << year << '\n'; // yyyy format str = getMonth(month); // prints in month (full word), day, year cout << str << " " << day << ", " << year << '\n'; } and my main.cpp #include <iostream> #include "Date.h" using std::cout; int main() { Date date1(4, 30, 1980); date1.print(); cout << '\n'; Date date2; date2.print(); }

    Read the article

< Previous Page | 73 74 75 76 77 78 79 80 81 82 83 84  | Next Page >