473,587 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IndentationErro r: expected an indented block

2 New Member
Getting the following error. But I cannot figure out why. Could someone please alter my code and explain where I am going wrong?


./checkprocess2.p y
File "./checkprocess2.p y", line 19
else:
^
IndentationErro r: expected an indented block

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/python
  2.  
  3. import sys
  4. import os
  5. import commands
  6.  
  7. def state():
  8.                output = commands.getoutput('ps -A')
  9.                if 'amun_server.py' in output:
  10.                        return false
  11.                else:
  12.                        return true
  13.  
  14. status = false
  15.  
  16. while true:
  17.     if state():
  18.  
  19.         else:
  20.                  os.system("/root/amun/amun_server.py &")
Jun 21 '10 #1
3 4475
bvdet
2,851 Recognized Expert Moderator Specialist
@cwggenius
The error message says it all! There must be a statement or some action after the if statement. Your indentation is wrong also. You don't need the else statement in function state().

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/python
  2.  
  3. import sys
  4. import os
  5. import commands
  6.  
  7. def state():
  8.     output = commands.getoutput('ps -A')
  9.     if 'amun_server.py' in output:
  10.         return false
  11.     return true
  12.  
  13. status = false
  14.  
  15. while true:
  16.     if state():
  17.         pass # there must be some action or statement
  18.     else:
  19.         os.system("/root/amun/amun_server.py &")
Jun 22 '10 #2
cwggenius
2 New Member
BVDET. Thank you for your reply...

I am now getting :

./checkprocess2.p y
Traceback (most recent call last):
File "./checkprocess2.p y", line 13, in <module>
status = false
NameError: name 'false' is not defined

...still a bit confused.
Jun 22 '10 #3
bvdet
2,851 Recognized Expert Moderator Specialist
Python is case-sensitive.

Expand|Select|Wrap|Line Numbers
  1. >>> false
  2. Traceback (most recent call last):
  3.   File "<interactive input>", line 1, in ?
  4. NameError: name 'false' is not defined
  5. >>> False
  6. False
  7. >>> 
Jun 22 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

699
33662
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it...
5
2595
by: beliavsky | last post by:
How do you keep Python code properly indented as you modify it? I use an Emacs-type editor that has a Python mode, so the initial indenting is easy. If I later want to put a 'for' loop (or an 'if' statement) around a bunch of code, I find myself going through the body of the loop, manually re-indenting to keep the nested loops correct. There...
0
1599
by: Mr. Magoo | last post by:
Why does py_compile print IndentationError in a different format than SyntaxError? It makes it harder to parse the output in a non-python program. Sorry: IndentationError: ('unindent does not match any outer indentation level', ('foo.py', 19, 17, '\t\t\t return 0.0 \n')) instead of File "foo.py", line 19
3
5477
by: David Ross | last post by:
I sometimes place a sidebar on a Web page, using the following: ..sideright { float: right; background-color: #fff; width: 40%; font-size: 90%; text-align: justify; margin-left: 1em; padding: 2% } ..sideleft { float: left; background-color: #fff;
0
1693
by: Bart Lateur | last post by:
This seems so basic, but the common browsers (in particular Firefox and MSIE on Windows) succeed to mess it up. The basic HTML is this: <!-- an image floating on the left --> <img align="left" src="image.gif"> <!-- a list on its right --> <ul> <li>one
39
13397
by: eruanion | last post by:
Hi, I've been working on this for a while now and I can't seem to find out what is wrong with my code. I have 2 files one c3common.js which only contains javascript functions for my main html page and my main html page which is test.html. They are of course part of a much bigger system of files but i have tracked down the problem to that...
7
3555
by: kagard | last post by:
Greetings: I'm brand new to Python and decided to write a syllogism solver for a class I'm taking. At the start of the program, I define a function that classifies the type of each statement in the syllogism. Python tells me that it is expecting an indented block at the s in "some". I can see what I'm doing wrong. Here's the code: def...
5
14638
by: casioculture | last post by:
Haha. How can I fix this!
3
2425
by: Paddy3118 | last post by:
Not python: but python type indented text Notice the blank line above. It could have several spaces or tabs, and still be a part of the block beginning 'Not python:': The block ends at the
6
2927
by: Harlan Messinger | last post by:
Please take a look at http://www.gavelcade.com/list_next_to_float.html How can I style a list so that if it appears next to a left-floated box as the first list does in this example, the list items, with their bullets, still appear indented relative to the text above and below the list (i.e., without having the bullets overlapping the...
0
7849
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3844
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.