ALT Linux Community general discussions
 help / color / mirror / Atom feed
* [Comm] python eject script
@ 2003-10-24  7:19 John A. Gladkikh
  2003-10-24 22:00 ` Евгений Косенко
  0 siblings, 1 reply; 6+ messages in thread
From: John A. Gladkikh @ 2003-10-24  7:19 UTC (permalink / raw)
  To: community

Hi All.
Вопрос знатокам питона.
Такой маленький скрипт.
На открытие работает, на закрытие нет
В файл все пишет правильно, наверное дело в вызове eject?
Как исправить, чтобы закрывало?
------------------------------------
#!/usr/bin/python

import os

name = "/home/vigio/tmp/cdd.tmp"

try:
   f = open(name, "r")
   s = f.readline()
   f.close()
except:
   s = "closed"

if s == "closed" :
    new_s = "open"
    cmdparam = ''
else:
    new_s = "closed"
    cmdparam = '-t'

f = open(name, "w")
f.write(new_s)
f.close()

retcode = os.spawnlp(os.P_WAIT, 'eject', cmdparam)

#
print new_s,cmdparam,retcode
#
-----------------------------------------------
Спасибо.

P.S.
Видел в рассылке скрипт для sh, хочется на питоне.
-- 

Best regards.
John A. Gladkikh.

   .~.	  Registered Linux User
   /U\	  # 315336
  // \\	  
 /(___)\
  ^   ^
	  


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-10-26 19:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-24  7:19 [Comm] python eject script John A. Gladkikh
2003-10-24 22:00 ` Евгений Косенко
2003-10-25  5:09   ` John A. Gladkikh
2003-10-25  7:50     ` Shrek
2003-10-25  8:17     ` Евгений Косенко
2003-10-26 19:27       ` Re[2]: " John A. Gladkikh

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git