ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: "John A. Gladkikh" <vigio@zt.kharkov.ua>
To: "community@altlinux.ru" <community@altlinux.ru>
Subject: [Comm] python eject script
Date: Fri, 24 Oct 2003 10:19:05 +0300
Message-ID: <20031024101905.48086e46.vigio@zt.kharkov.ua> (raw)

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
  // \\	  
 /(___)\
  ^   ^
	  


             reply	other threads:[~2003-10-24  7:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-24  7:19 John A. Gladkikh [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20031024101905.48086e46.vigio@zt.kharkov.ua \
    --to=vigio@zt.kharkov.ua \
    --cc=community@altlinux.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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