Data not flushed at the moment

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MindClass

    #1

    Data not flushed at the moment

    I've to modifying a file, then I use a method imported that access to
    that file and has to read the new data, but they are not read ( as if
    the data were not flushed at the moment even using .close()
    explicitly).

    ---------------------------------------
    ...
    ...
    # If it is not installed, it looking for the line and insert it.
    if not is_application:
    print "Activating I18n application ..."
    writefile_line = 0
    a = fileinput.input (settings, inplace=1)
    # for line in fileinput.input (settings, inplace=1):
    for line in a:
    writefile_line += 1
    if writefile_line == readfile_line:
    print " '%s'," % application_nam e
    print line[:-1]
    else:
    print line[:-1]
    a.close()

    update()

    def update():
    # Update the data base.
    try:
    from django.core.man agement import syncdb
    except ImportError, err:
    print "Can't import from Django: %s" % err
    sys.exit(1)

    syncdb()
    ---------------------------------------

    Note that it only fails if the update() method is run inner of 'if not
    is_application' , and I don't understand because it is happening so. But
    the problem is that I need run it when that condition is performed. Any
    idea?

  • MindClass

    #2
    Re: Data not flushed at the moment

    Here it's very well explained:


    syncdb() method:
    The Web framework for perfectionists with deadlines. - File not found · django/django


    But I'm not sure if is a django problem or from python.


    MindClass ha escrito:
    I've to modifying a file, then I use a method imported that access to
    that file and has to read the new data, but they are not read ( as if
    the data were not flushed at the moment even using .close()
    explicitly).
    >
    ---------------------------------------
    ...
    ...
    # If it is not installed, it looking for the line and insert it.
    if not is_application:
    print "Activating I18n application ..."
    writefile_line = 0
    a = fileinput.input (settings, inplace=1)
    # for line in fileinput.input (settings, inplace=1):
    for line in a:
    writefile_line += 1
    if writefile_line == readfile_line:
    print " '%s'," % application_nam e
    print line[:-1]
    else:
    print line[:-1]
    a.close()
    >
    update()
    >
    def update():
    # Update the data base.
    try:
    from django.core.man agement import syncdb
    except ImportError, err:
    print "Can't import from Django: %s" % err
    sys.exit(1)
    >
    syncdb()
    ---------------------------------------
    >
    Note that it only fails if the update() method is run inner of 'if not
    is_application' , and I don't understand because it is happening so. But
    the problem is that I need run it when that condition is performed. Any
    idea?

    Comment

    Working...