Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 18th, 2004, 09:35 AM
ronnyma ronnyma is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: OSLO
Posts: 17 ronnyma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to ronnyma
Please help debug.

Hello!

Can anyone see any error in this piece of code? (It is not made by me, but I cannot get it to work. It yields

./install.py: line 5: syntax error near unexpected token `faile(c'
./install.py: line 5: `def faile(cmd):'

when I utilize it.

Below is the code.

Thanks in advance,

Ronny Mandal


-- start --
# !/usr/bin/env python

import os,sys,shutil,re

def faile(cmd):
print '%s: Running %s failed' % (sys.argv[0],cmd)
sys.exit(1)

if os.name=='posix': # unix?
origdir=os.getcwd()
dir='install'
#if not os.path.isdir(dir):
# os.mkdir(dir)
os.chdir(dir)

print 'Generating makefile using qmake.........'
cmd='qmake'
failure=os.system(cmd)
if failure: faile(cmd)

print 'Attempting make...'
cmd='make'
failure=os.system(cmd)
if failure: faile(cmd)

print 'Cleaning objekt files....'
cmd='rm *.o Makefile'
failure=os.system(cmd)
if failure: faile(cmd)

cmd='mv MuseSveis ../'
failure=os.system(cmd)
if failure: faile(cmd)

os.chdir(origdir)
print 'Run by typing MuseSveis'
else:
print 'Use linux!!\n'

-- end --

Reply With Quote
  #2  
Old June 18th, 2004, 09:44 AM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,221 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 22 h 21 m 4 sec
Reputation Power: 263
The first error is that the code has not been posted with [ CODE] tags, so the indentation is lost.

I can't find the second error until the first is fixed.

Dave - The Developers' Coach

Reply With Quote
  #3  
Old June 18th, 2004, 10:56 AM
ronnyma ronnyma is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: OSLO
Posts: 17 ronnyma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to ronnyma
Quote:
Originally Posted by DevCoach
The first error is that the code has not been posted with [ CODE] tags, so the indentation is lost.

I can't find the second error until the first is fixed.

Dave - The Developers' Coach



--

Sorry, here it is again.

Regards,

RM

Code:
# !/usr/bin/env python

import os,sys,shutil,re

def faile(cmd):
        print '%s: Running %s failed' # (sys.argv[0],cmd)
        sys.exit(1)

if os.name=='posix':                # unix?
        origdir=os.getcwd()
        dir='install'
        #if not os.path.isdir(dir):
        #       os.mkdir(dir)
        os.chdir(dir)

        print 'Generating makefile using qmake.........'
        cmd='qmake'
        failure=os.system(cmd)
        if failure: faile(cmd)

        print 'Attempting make...'
        cmd='make'
        failure=os.system(cmd)
        if failure: faile(cmd)

        print 'Cleaning objekt files....'
        cmd='rm *.o Makefile'
        failure=os.system(cmd)
        if failure: faile(cmd)

        cmd='mv MuseSveis ../'
        failure=os.system(cmd)
        if failure: faile(cmd)

        os.chdir(origdir)
        print 'Run by typing MuseSveis'
else:
        print 'Use linux!!\n'

Reply With Quote
  #4  
Old June 18th, 2004, 11:46 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 3 m 4 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
First problem that comes to mind is that os.system() returns 0 if the command goes well - since to OS's 0 is true and none 0 is false, on the other hand, Python sees this a little differently. What this means to you?

Is you need to change lines like this..

Code:
failure = os.system(cmd)
if failure: faile(cmd)


into something like..

Code:
success = os.system(cmd)
if not success: faile(cmd)


I may be wrong, but that makes a lot of sence to me . Then i am a little odd .

Hope this helps,

Mark.
__________________
programming language development: www.netytan.com Hula


Reply With Quote
  #5  
Old June 18th, 2004, 11:48 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,536 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 3 m 4 sec
Reputation Power: 63
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
You might also want to loose re, and shutil from your import statment since they are not being used anywhere in the program as of yet . This means that you have to waist time importing something your program never uses.

Mark.

Reply With Quote
  #6  
Old June 18th, 2004, 02:24 PM
ronnyma ronnyma is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: OSLO
Posts: 17 ronnyma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to ronnyma
Thanks, but

thanks alot, but I still get the error message 'error near unexpected token..." as recently.

It seems like they've done a wrong declaration of the 'faile'. Or...

Hmm..

I appreciate all help.


Cheers!

Reply With Quote
  #7  
Old June 18th, 2004, 03:52 PM
DevCoach DevCoach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2004
Location: London, England
Posts: 1,221 DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level)DevCoach User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 5 Days 22 h 21 m 4 sec
Reputation Power: 263
That line looks ok, but is it possible that it is not using the regular ASCII character set? If it is has a character from the extended unicode char set in the line, then it may make Python choke. That is the only thing I can think of that would cause that error message.

Try examining the original file in hex.

Dave - The Developers' Coach

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Please help debug.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway