Ticket #13147: 13147_move.patch

File 13147_move.patch, 42.8 KB (added by roed, 9 years ago)

David Roe/Robert? Bradshaw's original solution: I don't like it as much as Mike's

  • sage/all.py

    # HG changeset patch
    # User David Roe <roed.math@gmail.com>
    # Date 1332357398 25200
    # Node ID 0770926c000e083c01f51454aadf7c0ec63aafcf
    # Parent  d5389174721c2d6febfeac7091437e1c30a305b7
    [mq]: tempfiles.patch
    
    diff --git a/sage/all.py b/sage/all.py
    a b  
    253253    #        except OSError:  # ERROR, fd wasn't open to begin with (ignored)
    254254    #            pass
    255255    # Now delete the temp files
    256     #from sage.misc.misc import delete_tmpfiles
     256    #from sage.misc.tempfiles import delete_tmpfiles
    257257    #delete_tmpfiles()
    258258
    259259    # stop the twisted reactor
  • sage/coding/linear_code.py

    diff --git a/sage/coding/linear_code.py b/sage/coding/linear_code.py
    a b  
    263263        sage: f.close()
    264264   
    265265    """
    266     from sage.misc.misc import tmp_filename
     266    from sage.misc.tempfiles import tmp_filename
    267267    F = C.base_ring()
    268268    p = F.order()  # must be prime and <11
    269269    s = "LIBRARY code;\n"+"code=seq(%s,%s,%s,seq(\n"%(p,C.dimension(),C.length())
     
    23712371            guava_bin_dir = gap.eval('DirectoriesPackageLibrary( "guava" )')
    23722372            guava_bin_dir = guava_bin_dir[1:-1].strip()[5:-6] + 'bin/'
    23732373            input = code2leon(self)
    2374             from sage.misc.misc import tmp_filename
     2374            from sage.misc.tempfiles import tmp_filename
    23752375            output = tmp_filename()
    23762376            import os
    23772377            status = os.system(guava_bin_dir + "wtdist " + input + "::code > " + output)
  • sage/combinat/designs/ext_rep.py

    diff --git a/sage/combinat/designs/ext_rep.py b/sage/combinat/designs/ext_rep.py
    a b  
    3939import os.path
    4040import gzip
    4141import bz2
    42 from sage.misc.misc import tmp_filename
     42import sage.misc.tempfiles as tmp
    4343import urllib2
    4444import sys
    4545
     
    476476        sage: os.remove(file_loc)
    477477    """
    478478
    479     file_loc = tmp_filename()
     479    file_loc = tmp.tmp_filename()
    480480    f = open(file_loc,"w")
    481481    f.write(v2_b2_k2_icgsa)
    482482    f.close()
  • sage/databases/sql_db.py

    diff --git a/sage/databases/sql_db.py b/sage/databases/sql_db.py
    a b  
    8080import sqlite3 as sqlite
    8181import os
    8282import re
    83 from sage.misc.misc import tmp_filename
     83import sage.misc.tempfiles as tmp
    8484from sage.structure.sage_object import SageObject
    8585
    8686sqlite_keywords = ['ABORT','ACTION','ADD','AFTER','ALL','ALTER','ANALYZE',
     
    10421042        if filename is None:
    10431043            if read_only is None:
    10441044                read_only = False
    1045             filename = tmp_filename() + '.db'
     1045            filename = tmp.tmp_filename() + '.db'
    10461046        elif (filename[-3:] != '.db'):
    10471047            raise ValueError('Please enter a valid database path (file name ' \
    10481048                + '%s does not end in .db).'%filename)
     
    11371137            1                    4                    978932
    11381138        """
    11391139        # copy .db file
    1140         new_loc = tmp_filename() + '.db'
     1140        new_loc = tmp.tmp_filename() + '.db'
    11411141        if not self.__read_only__:
    11421142            self.commit()
    11431143        os.system('cp '+ self.__dblocation__ + ' ' + new_loc)
  • sage/geometry/lattice_polytope.py

    diff --git a/sage/geometry/lattice_polytope.py b/sage/geometry/lattice_polytope.py
    a b  
    103103from sage.graphs.all import Graph
    104104from sage.interfaces.all import maxima
    105105from sage.matrix.all import matrix, is_Matrix
    106 from sage.misc.all import tmp_filename
     106import sage.misc.tempfiles as tmp
    107107from sage.misc.misc import deprecation, SAGE_DATA
    108108from sage.modules.all import vector
    109109from sage.plot.plot3d.index_face_set import IndexFaceSet
     
    42974297        sage: f.close()
    42984298        sage: os.remove(result_name)
    42994299    """               
    4300     input_file_name = tmp_filename()
     4300    input_file_name = tmp.tmp_filename()
    43014301    input_file = open(input_file_name, "w")
    43024302    for p in polytopes:
    43034303        if p.dim() == 0:
     
    43084308            "in a %d-dimensional space!") % (p.dim(), p.ambient_dim()))               
    43094309        write_palp_matrix(p._pullback(p._vertices), input_file)
    43104310    input_file.close()
    4311     output_file_name = tmp_filename()
     4311    output_file_name = tmp.tmp_filename()
    43124312    c = "%s <%s >%s" % (command, input_file_name, output_file_name)
    43134313    p = subprocess.Popen(c, shell=True, bufsize=2048,
    43144314                     stdin=subprocess.PIPE,
  • sage/geometry/polyhedra.py

    diff --git a/sage/geometry/polyhedra.py b/sage/geometry/polyhedra.py
    a b  
    118118from sage.categories.objects import Objects
    119119
    120120from subprocess import Popen, PIPE
    121 from sage.misc.all import tmp_filename, cached_method, prod
     121from sage.misc.all import cached_method, prod
     122import sage.misc.tempfiles as tmp
    122123from sage.misc.functional import norm
    123124from sage.misc.package import is_package_installed
    124125
     
    42854286
    42864287        in_str = self.cdd_Vrepresentation()
    42874288        in_str += 'volume'
    4288         in_filename = tmp_filename()
     4289        in_filename = tmp.tmp_filename()
    42894290        in_file = file(in_filename,'w')
    42904291        in_file.write(in_str)
    42914292        in_file.close()
  • sage/geometry/polytope.py

    diff --git a/sage/geometry/polytope.py b/sage/geometry/polytope.py
    a b  
    3434#                  http://www.gnu.org/licenses/
    3535########################################################################
    3636
    37 
    38 from sage.misc.all import SAGE_TMP, tmp_filename
     37import sage.misc.tempfiles as tmp
    3938from sage.rings.all import Integer, QQ
    4039from sage.structure.all import Sequence
    4140from sage.modules.all import VectorSpace
     
    5049if os.path.exists(path):
    5150    os.environ['PATH'] = '%s:'%path + os.environ['PATH']
    5251
    53 tmp_file = '%s/tmp.poly'%SAGE_TMP
    54 
    5552class Polytope(SageObject):
    5653    """
    5754    Create a polytope.
     
    9390        """
    9491        if not isinstance(other, Polytope):
    9592            raise TypeError, "other (=%s) must be a polytope"%other
    96         output_file = tmp_filename()
    97         infile1 = tmp_filename()
     93        output_file = tmp.tmp_filename()
     94        infile1 = tmp.tmp_filename()
    9895        open(infile1,'w').write(self.__data)
    99         infile2 = tmp_filename()
     96        infile2 = tmp.tmp_filename()
    10097        open(infile2,'w').write(other.__data)       
    10198        cmd = "minkowski_sum %s 1 %s 1 %s"%(output_file, infile1,
    10299                                            infile2)
     
    134131                j += i
    135132            return D[i+len(cmd2)-1:j]
    136133       
    137         F = tmp_file
     134        F = '%s/tmp.poly'%tmp.SAGE_TMP
    138135        open(F,'w').write(self.__data)
    139136        c = '%s %s %s'%(polymake_command, F, cmd)
    140137        polymake_processes = Popen([polymake_command, F, cmd],stdout=PIPE,stderr=PIPE)
     
    259256
    260257    def __make(self, cmd, name):
    261258        os.system(cmd)
     259        tmp_file = '%s/tmp.poly'%tmp.SAGE_TMP
    262260        try:
    263261            d = open(tmp_file).read()
    264262        except IOError:
     
    275273        os.system("polymake --reconfigure")
    276274
    277275    def associahedron(self, dimension):
     276        tmp_file = '%s/tmp.poly'%tmp.SAGE_TMP
    278277        return self.__make('associahedron %s %s'%(tmp_file, dimension),
    279278                           '%s-dimensional associahedron'%dimension)   
    280279                       
    281280    def birkhoff(self, n):
     281        tmp_file = '%s/tmp.poly'%tmp.SAGE_TMP
    282282        return self.__make('birkhoff %s %s'%(tmp_file, n),
    283283                           'Birkhoff %s'%n)
    284284                       
     
    290290            sage: polymake.cell24()            # optional: needs polymake
    291291            The 24-cell
    292292        """
     293        tmp_file = '%s/tmp.poly'%tmp.SAGE_TMP
    293294        return self.__make('24-cell %s'%tmp_file,
    294295                           'The 24-cell')
    295296   
     
    321322        return Polytope(f, 'Convex hull of points %s'%points)
    322323
    323324    def cube(self, dimension, scale=0):
     325        tmp_file = '%s/tmp.poly'%tmp.SAGE_TMP
    324326        return self.__make('cube %s %s %s'%(tmp_file, dimension, scale),
    325327                           'Cube of dimension %s (scale %s)'%(dimension, scale))
    326328
     
    328330        return Polytope(data, 'A Polytope')
    329331
    330332    def rand01(self, d, n, seed=None):
     333        tmp_file = '%s/tmp.poly'%tmp.SAGE_TMP
    331334        cmd = 'rand01 %s %s %s'%(tmp_file, d, n)
    332335        if not seed is None:
    333336            cmd += ' -seed %s'%seed
  • sage/interfaces/cleaner.py

    diff --git a/sage/interfaces/cleaner.py b/sage/interfaces/cleaner.py
    a b  
    1414###############################################################################
    1515import os
    1616
    17 import sage.misc.misc as misc
    18 F = '%s/spawned_processes'%misc.SAGE_TMP
     17import sage.misc.tempfiles as tmp
    1918
    2019def cleaner(pid, cmd=''):
     20    F = os.path.join(tmp.SAGE_TMP, 'spawned_processes')
    2121    if cmd != '':
    2222        cmd = cmd.strip().split()[0]
    2323    # This is safe, since only this process writes to this file.
    2424    if os.path.exists(F):
    2525        o = open(F,'a')
    2626    else:
    27         if not os.path.exists(misc.SAGE_TMP):
     27        if not os.path.exists(tmp.SAGE_TMP):
    2828            return
    2929        o = open(F,'w')
    3030    o.write('%s %s\n'%(pid, cmd))
     
    3434################
    3535
    3636def start_cleaner_if_not_running():
    37     D = '%s/tmp_cleaner.pid'%misc.DOT_SAGE
     37    D = '%s/tmp_cleaner.pid'%tmp.DOT_SAGE
    3838    try:
    3939        pid = int(open(D).read())
    4040        os.kill(pid,0)
  • sage/interfaces/ecm.py

    diff --git a/sage/interfaces/ecm.py b/sage/interfaces/ecm.py
    a b  
    1111from math import ceil, floor
    1212
    1313from sage.rings.integer import Integer
    14 from sage.misc.misc import verbose, tmp_filename
     14from sage.misc.misc import verbose
     15import sage.misc.tempfiles as tmp
    1516from sage.misc.decorators import rename_keyword
    1617
    1718import cleaner
     
    100101        self._validate(n)
    101102        cmd = 'echo "%s" | %s'%(n, self.__cmd)
    102103        if watch:
    103             t = tmp_filename()
     104            t = tmp.tmp_filename()
    104105            os.system('%s | tee %s'%(cmd, t))
    105106            ou = open(t).read()
    106107            os.unlink(t)
  • sage/interfaces/expect.py

    diff --git a/sage/interfaces/expect.py b/sage/interfaces/expect.py
    a b  
    6767from sage.structure.element import RingElement
    6868
    6969import sage.misc.sage_eval
    70 from sage.misc.misc import SAGE_ROOT, verbose, SAGE_TMP_INTERFACE, LOCAL_IDENTIFIER
     70import sage.misc.tempfiles as tmp
     71from sage.misc.misc import SAGE_ROOT, verbose
    7172from sage.misc.object_multiplexer import Multiplex
    7273
    7374BAD_SESSION = -2
    7475
    7576failed_to_start = []
    7677
    77 #tmp_expect_interface_local='%s/tmp'%SAGE_TMP_INTERFACE
     78#tmp_expect_interface_local='%s/tmp'%tmp.SAGE_TMP_INTERFACE
    7879
    7980#def tmp_expect_interface_local():
    80 #    return '%s/tmp'%SAGE_TMP_INTERFACE + str(os.getpid())
     81#    return '%s/tmp'%tmp.SAGE_TMP_INTERFACE + str(os.getpid())
    8182
    8283## On some platforms, e.g., windows, this can easily take 10 seconds!?!  Terrible.  And
    8384## it should not be necessary or used anyways.
     
    620621        - Simon King (2010-09): Making the tmp-file unique for the interface instance
    621622
    622623        """
    623         #return '%s/tmp'%SAGE_TMP_INTERFACE + str(self.pid())
     624        #return '%s/tmp'%tmp.SAGE_TMP_INTERFACE + str(self.pid())
    624625        try:
    625626            return self.__local_tmpfile
    626627        except AttributeError:
    627             self.__local_tmpfile = '%s/tmp'%SAGE_TMP_INTERFACE + str(self.pid())
     628            self.__local_tmpfile = '%s/tmp'%tmp.SAGE_TMP_INTERFACE + str(self.pid())
    628629            return self.__local_tmpfile
    629630
    630631    def _remote_tmpdir(self):
     
    634635        try:
    635636            return self.__remote_tmpfile
    636637        except AttributeError:
    637             self.__remote_tmpfile = self._remote_tmpdir()+"/interface_%s:%s"%(LOCAL_IDENTIFIER,self.pid())
     638            self.__remote_tmpfile = self._remote_tmpdir()+"/interface_%s:%s"%(tmp.LOCAL_IDENTIFIER,self.pid())
    638639            return self.__remote_tmpfile
    639640
    640641    def _send_tmpfile_to_server(self, local_file=None, remote_file=None):
     
    12361237       
    12371238        try:
    12381239            with gc_disabled():
    1239                 if (split_lines is "nofile" and allow_use_file and
     1240                if (split_lines == "nofile" and allow_use_file and
    12401241                        self._eval_using_file_cutoff and len(code) > self._eval_using_file_cutoff):
    12411242                    return self._eval_line_using_file(code)
    12421243                elif split_lines:
  • sage/interfaces/macaulay2.py

    diff --git a/sage/interfaces/macaulay2.py b/sage/interfaces/macaulay2.py
    a b  
    214214       
    215215        TESTS::
    216216               
    217             sage: from sage.misc.misc import tmp_filename
    218217            sage: filename = tmp_filename()
    219218            sage: f = open(filename, "w")
    220219            sage: f.write("sage_test = 7;")
  • sage/interfaces/magma.py

    diff --git a/sage/interfaces/magma.py b/sage/interfaces/magma.py
    a b  
    231231SAGE_REF_RE = re.compile('%s\d+'%SAGE_REF)
    232232
    233233import sage.misc.misc
     234import sage.misc.tempfiles as tempfiles
    234235import sage.misc.sage_eval
    235236
    236237INTRINSIC_CACHE = '%s/magma_intrinsic_cache.sobj'%sage.misc.misc.DOT_SAGE
     
    250251    global EXTCODE_DIR
    251252    if not EXTCODE_DIR:
    252253        import shutil
    253         tmp = sage.misc.misc.tmp_dir()
     254        tmp = tempfiles.tmp_dir()
    254255        shutil.copytree('%s/magma/'%sage.misc.misc.SAGE_EXTCODE, tmp + '/data')
    255256        EXTCODE_DIR = "%s/data/"%tmp
    256257    return EXTCODE_DIR
  • sage/interfaces/phc.py

    diff --git a/sage/interfaces/phc.py b/sage/interfaces/phc.py
    a b  
    3030
    3131import os
    3232
    33 import sage.misc.misc
     33import sage.misc.tempfiles as tmp
    3434from sage.rings.real_mpfr import RR
    3535from sage.rings.all import CC
    3636from sage.rings.integer import Integer
     
    406406            sage: a = phc._output_from_command_list(['phc -m','4','n','n','n'], start_sys)#optional
    407407        """
    408408        # Get temporary file names (these will be in SAGE_HOME/.sage/tmp/pid)
    409         input_filename = sage.misc.misc.tmp_filename()
    410         output_filename = sage.misc.misc.tmp_filename()
     409        input_filename = tmp.tmp_filename()
     410        output_filename = tmp.tmp_filename()
    411411       
    412412        # Get the input polynomial text
    413413        input = self._input_file(polys)
     
    585585        """
    586586        # Probably unnecessarily redundant from the start_from function
    587587        if start_filename_or_string.find('THE SOLUTIONS') != -1:
    588             start_filename = sage.misc.misc.tmp_filename()
     588            start_filename = tmp.tmp_filename()
    589589            start_file = file(start_filename,'w')
    590590            start_file.write(start_filename_or_string)
    591591            start_file.close()
     
    753753            sage: len(sol.solutions())                     #optional
    754754            30
    755755        """
    756         input_filename = sage.misc.misc.tmp_filename()
    757         output_filename = sage.misc.misc.tmp_filename()
     756        input_filename = tmp.tmp_filename()
     757        output_filename = tmp.tmp_filename()
    758758
    759759        if start_filename_or_string.find('THE SOLUTIONS') != -1:
    760             start_filename = sage.misc.misc.tmp_filename()
     760            start_filename = tmp.tmp_filename()
    761761            start_file = file(start_filename,'w')
    762762            start_file.write(start_filename_or_string)
    763763            start_file.close()
     
    847847        """
    848848           
    849849        # Get three temporary file names (these will be in SAGE_HOME/.sage/tmp/pid)
    850         input_filename = sage.misc.misc.tmp_filename()
    851         output_filename = sage.misc.misc.tmp_filename()
    852         log_filename = sage.misc.misc.tmp_filename()
     850        input_filename = tmp.tmp_filename()
     851        output_filename = tmp.tmp_filename()
     852        log_filename = tmp.tmp_filename()
    853853
    854854        # Get the input polynomial text
    855855        input = self._input_file(polys)
  • sage/interfaces/psage.py

    diff --git a/sage/interfaces/psage.py b/sage/interfaces/psage.py
    a b  
    5353        if kwds.has_key('server'):
    5454            raise NotImplementedError, "PSage doesn't work on remote server yet."
    5555        Sage.__init__(self, **kwds)
    56         import sage.misc.misc
    57         T = sage.misc.misc.tmp_dir('sage_smp')
     56        import sage.misc.tempfiles as tmp
     57        T = tmp.tmp_dir('sage_smp')
    5858        self.__tmp_dir = T
    5959        self.__tmp = '%s/lock'%T
    6060        self._unlock()
  • sage/interfaces/qsieve.py

    diff --git a/sage/interfaces/qsieve.py b/sage/interfaces/qsieve.py
    a b  
    88
    99import sage.rings.integer
    1010
    11 from sage.misc.all import tmp_dir
    12 
    1311_tmp_dir = False
    1412def tmpdir():
    1513    global _tmp_dir
    1614    if _tmp_dir:
    1715        return
     16    from sage.misc.all import tmp_dir
    1817    X = tmp_dir('qsieve')
    1918    os.environ['TMPDIR'] = X
    2019    _tmp_dir = True
  • sage/interfaces/quit.py

    diff --git a/sage/interfaces/quit.py b/sage/interfaces/quit.py
    a b  
    6363
    6464        sage: sage.interfaces.quit.expect_quitall()
    6565    """
    66     from sage.misc.misc import SAGE_TMP
     66    from sage.misc.tempfiles import SAGE_TMP
    6767    file = os.path.join(SAGE_TMP, 'spawned_processes')
    6868    if not os.path.exists(file):
    6969        return
  • sage/interfaces/sage0.py

    diff --git a/sage/interfaces/sage0.py b/sage/interfaces/sage0.py
    a b  
    284284        EXAMPLES::
    285285       
    286286            sage: sage0._quit_string()
    287             'from sage.misc.misc import delete_tmpfiles; delete_tmpfiles()'
     287            'from sage.misc.tempfiles import delete_tmpfiles; delete_tmpfiles()'
    288288        """
    289         return 'from sage.misc.misc import delete_tmpfiles; delete_tmpfiles()'
     289        return 'from sage.misc.tempfiles import delete_tmpfiles; delete_tmpfiles()'
    290290
    291291    def preparse(self, x):
    292292        """
  • sage/interfaces/tachyon.py

    diff --git a/sage/interfaces/tachyon.py b/sage/interfaces/tachyon.py
    a b  
    88
    99
    1010from sage.misc.pager import pager
    11 from sage.misc.misc import tmp_filename
     11import sage.misc.tempfiles as tmp
    1212from sage.misc.sagedoc import format
    1313import os
    1414
     
    9999            sage: t(tgen.str(), outfile = os.devnull)
    100100            tachyon ...
    101101        """
    102         modelfile = tmp_filename() + '.dat'
     102        modelfile = tmp.tmp_filename() + '.dat'
    103103        open(modelfile,'w').write(model)
    104104        opts = ''
    105105        ext = outfile[-4:].lower()
  • sage/misc/all.py

    diff --git a/sage/misc/all.py b/sage/misc/all.py
    a b  
    44                  version, banner, add, union, uniq, powerset, subsets,
    55                  exists, forall, is_iterator,
    66                  random_sublist, mul, walltime, generic_cmp,
    7                   repr_lincomb, tmp_dir, tmp_filename,
    8                   pad_zeros, attrcall,
    9                   DOT_SAGE, SAGE_ROOT, SAGE_URL, SAGE_DB, SAGE_TMP,
     7                  repr_lincomb, pad_zeros, attrcall,
     8                  DOT_SAGE, SAGE_ROOT, SAGE_URL, SAGE_DB,
    109                  is_32_bit, is_64_bit, newton_method_sizes, compose,
    1110                  self_compose, nest)
     11from tempfiles import SAGE_TMP, tmp_dir, tmp_filename
    1212
    1313from misc_c import prod, running_total, balanced_sum
    1414
  • sage/misc/citation.pyx

    diff --git a/sage/misc/citation.pyx b/sage/misc/citation.pyx
    a b  
    1 from sage.misc.all import tmp_filename, preparse, SAGE_ROOT
     1from sage.misc.all import preparse, SAGE_ROOT
     2import sage.misc.tempfiles as tmp
    23
    34systems = {}
    45systems['PARI'] = ['sage.libs.pari', 'sage.interfaces.gp']
     
    7677    cmd = preparse(cmd)
    7778
    7879    #Run the command and get the stats
    79     filename = tmp_filename()
     80    filename = tmp.tmp_filename()
    8081    cProfile.runctx(cmd, globals(), {}, filename)
    8182    stats = pstats.Stats(filename)
    8283
  • sage/misc/cython.py

    diff --git a/sage/misc/cython.py b/sage/misc/cython.py
    a b  
    1717
    1818import os, sys, platform
    1919
    20 from misc import SPYX_TMP, SAGE_ROOT, SAGE_LOCAL
     20import tempfiles as tmp
     21from misc import SAGE_ROOT, SAGE_LOCAL
    2122from sage.misc.misc import UNAME
    2223
    2324def cblas():
     
    279280    # This is the *temporary* directory where we build the pyx file.
    280281    # This is deleted when sage exits, which means pyx files must be
    281282    # rebuilt every time Sage is restarted at present.
    282     build_dir = '%s/%s'%(SPYX_TMP, base)
     283    build_dir = '%s/%s'%(tmp.SPYX_TMP, base)
    283284
    284285    if os.path.exists(build_dir):
    285286        # There is already a module here.  Maybe we do not have to rebuild?
     
    534535    if verbose:
    535536        print s
    536537    import sage.misc.misc
    537     tmpfile = sage.misc.misc.tmp_filename() + ".spyx"
     538    tmpfile = tmp.tmp_filename() + ".spyx"
    538539    open(tmpfile,'w').write(s)
    539540
    540541    import sage.server.support
     
    626627        sage: module.f(10)
    627628        100
    628629    """
    629     from sage.misc.misc import tmp_filename
    630     file = tmp_filename() + ".pyx"
     630    file = tmp.tmp_filename() + ".pyx"
    631631    open(file,'w').write(code)
    632632    from sage.server.support import cython_import
    633633    return cython_import(file, create_local_c_file=False)
  • sage/misc/cython_c.pyx

    diff --git a/sage/misc/cython_c.pyx b/sage/misc/cython_c.pyx
    a b  
    1 import sage.misc.misc
     1import sage.misc.tempfiles as tmp
    22import sage.server.support
    33
    44def cython(code,
     
    5656        Need to create a clever caching system so code only gets
    5757        compiled once.
    5858    """
    59     tmpfile = sage.misc.misc.tmp_filename() + ".spyx"
     59    tmpfile = tmp.tmp_filename() + ".spyx"
    6060    open(tmpfile,'w').write(code)
    6161    sage.server.support.cython_import_all(tmpfile, globals(),
    6262                                         verbose=verbose, compile_message=compile_message,
  • sage/misc/dev_tools.py

    diff --git a/sage/misc/dev_tools.py b/sage/misc/dev_tools.py
    a b  
    4949
    5050    """
    5151    import cProfile, os
    52     from sage.misc.misc import tmp_filename, get_main_globals
     52    from sage.misc.misc import get_main_globals
     53    from sage.misc.tempfiles import tmp_filename
    5354    from sage.misc.preparser import preparse
    5455    tmpfile = tmp_filename()
    5556    cProfile.runctx(preparse(command.lstrip().rstrip()), get_main_globals(), locals(), filename=tmpfile)
  • sage/misc/hg.py

    diff --git a/sage/misc/hg.py b/sage/misc/hg.py
    a b  
    7373import os, shutil
    7474
    7575from   viewer import browser
    76 from   misc   import tmp_filename, branch_current_hg, embedded
     76import sage.misc.tempfiles as tmp
     77from   misc   import branch_current_hg, embedded
    7778from   remote_file import get_remote_file as get_remote_file0
    7879from   sage.server.misc import print_open_msg
    7980from   subprocess import Popen
     
    438439        if open_viewer:
    439440            cmd = 'sleep 1; %s http://%s:%s 1>&2 >/dev/null'%(browser(),
    440441                                                              address, port)
    441             t = tmp_filename()
     442            t = tmp.tmp_filename()
    442443            open(t,'w').write(cmd)
    443444            P = os.path.abspath(t)
    444445            os.system('chmod +x %s; %s &'%(P, P))
  • sage/misc/inline_fortran.py

    diff --git a/sage/misc/inline_fortran.py b/sage/misc/inline_fortran.py
    a b  
    11import __builtin__
    22import os
    33
    4 from sage.misc.misc import tmp_filename
     4import sage.misc.tempfiles as tmp
    55
    66count=0
    77
     
    4646        cwd=os.getcwd()
    4747        os.sys.path.append(cwd)
    4848
    49         #name = tmp_dir() + '/fortran_module_%d'%count
     49        #name = tmp.tmp_dir() + '/fortran_module_%d'%count
    5050        name = 'fortran_module_%d'%count
    5151        if os.path.exists(name):
    5252            os.unlink(name)
     
    6161        # if the first line has !f90 as a comment gfortran will treat it as
    6262        # fortran 90 code
    6363        if x.startswith('!f90'):       
    64             fname = os.path.join(tmp_filename() +'.f90')
     64            fname = os.path.join(tmp.tmp_filename() +'.f90')
    6565        else:
    66             fname = os.path.join(tmp_filename() +'.f')
     66            fname = os.path.join(tmp.tmp_filename() +'.f')
    6767
    68         log = tmp_filename()
     68        log = tmp.tmp_filename()
    6969        extra_args = '--quiet --f77exec=%s --f90exec=%s %s %s  1>&2 >"%s"'%(
    7070                    path, path, s_lib_path, s_lib, log)
    7171
  • sage/misc/interpreter.py

    diff --git a/sage/misc/interpreter.py b/sage/misc/interpreter.py
    a b  
    378378    Preparse file named \code{name} (presumably a .sage file), outputting to a
    379379    temporary file.  Returns name of temporary file.
    380380    """
    381     import sage.misc.misc
     381    import sage.misc.tempfiles as tmp
    382382    name = os.path.abspath(name)
    383     tmpfilename = os.path.abspath(sage.misc.misc.tmp_filename(name) + ".py")
     383    tmpfilename = os.path.abspath(tmp.tmp_filename(name) + ".py")
    384384    out = open(tmpfilename,'w')
    385385    preparse_file_named_to_stream(name, out)
    386386    out.close()
  • sage/misc/latex.py

    diff --git a/sage/misc/latex.py b/sage/misc/latex.py
    a b  
    5454import subprocess
    5555import types
    5656
    57 from misc import tmp_dir, graphics_filename
     57import sage.misc.tempfiles as tempfiles
     58from misc import graphics_filename
    5859import sage_eval
    5960from sage.misc.sage_ostools import have_program
    6061from sage.misc.cachefunc import cached_function, cached_method
     
    966967            filename = 'sage%s'%random.randint(1,100) # to defeat browser caches
    967968        else:
    968969            filename = os.path.splitext(filename)[0]  # get rid of extension
    969         base = tmp_dir()
     970        base = tempfiles.tmp_dir()
    970971        orig_base, filename = os.path.split(os.path.abspath(filename))
    971972        if len(filename.split()) > 1:
    972973            raise ValueError, "filename must contain no spaces"
     
    19961997        engine = _Latex_prefs._option["engine"]
    19971998        if viewer == "pdf" and engine == "latex":
    19981999            engine = "pdflatex"
    1999     tmp = tmp_dir('sage_viewer')
     2000    tmp = tempfiles.tmp_dir('sage_viewer')
    20002001    tex_file = os.path.join(tmp, "sage.tex")
    20012002    open(tex_file,'w').write(s)
    20022003    suffix = _run_latex_(tex_file, debug=debug, engine=engine, png=False)
     
    20652066    # path name for permanent png output
    20662067    abs_path_to_png = os.path.abspath(filename)
    20672068    # temporary directory to store stuff
    2068     tmp = tmp_dir('sage_viewer')
     2069    tmp = tempfiles.tmp_dir('sage_viewer')
    20692070    tex_file = os.path.join(tmp, "sage.tex")
    20702071    png_file = os.path.join(tmp, "sage.png")
    20712072    # write latex string to file
  • sage/misc/misc.py

    diff --git a/sage/misc/misc.py b/sage/misc/misc.py
    a b  
    4444SAGE_DOC = os.environ["SAGE_DOC"]
    4545HOSTNAME = socket.gethostname().replace('-','_').replace('/','_').replace('\\','_')
    4646
    47 LOCAL_IDENTIFIER = '%s.%s'%(HOSTNAME , os.getpid())
    48 
    4947def sage_makedirs(dir):
    5048    """
    5149    Python version of ``mkdir -p``: try to create a directory, and also
     
    127125    # Change mode of DOT_SAGE.
    128126    os.chmod(DOT_SAGE, _desired_mode)
    129127
    130 
    131 #################################################
    132 # Next we create the Sage temporary directory.
    133 # It is called temp instead of tmp mainly for
    134 # "historical reasons"...
    135 
    136 SAGE_TMP='%s/temp/%s/%s/'%(DOT_SAGE, HOSTNAME, os.getpid())
    137 
    138 sage_makedirs(SAGE_TMP)
    139 
    140128SAGE_DATA = '%s/data/'%SAGE_ROOT
    141129SAGE_EXTCODE = '%s/data/extcode/'%SAGE_ROOT
    142 SPYX_TMP = '%s/spyx/'%SAGE_TMP
    143 
    144 
    145 def delete_tmpfiles():
    146     # !!!If you change this, see also SAGE_ROOT/local/bin/sage-doctest!!!
    147     import shutil
    148     try:
    149         if os.path.exists(SAGE_TMP):
    150             shutil.rmtree(SAGE_TMP)
    151     except OSError, msg:
    152         print msg
    153         pass
    154 
    155 SAGE_TMP_INTERFACE='%s/interface/'%SAGE_TMP
    156 sage_makedirs(SAGE_TMP_INTERFACE)
    157130
    158131SAGE_DB = '%s/db'%DOT_SAGE
    159132sage_makedirs(SAGE_DB)
     
    19581931import pdb
    19591932set_trace = pdb.set_trace
    19601933
    1961 
    19621934#################################################################
    1963 # temporary directory
     1935# graphics filenames
    19641936#################################################################
    19651937
    1966 def tmp_dir(name='dir'):
    1967     r"""
    1968     Create and return a temporary directory in
    1969     ``$HOME/.sage/temp/hostname/pid/``
    1970     """
    1971     name = str(name)
    1972     n = 0
    1973     while True:
    1974         tmp = "%s/%s_%s"%(SAGE_TMP, name, n)
    1975         if not os.path.exists(tmp):
    1976             break
    1977         n += 1
    1978     try:
    1979         os.makedirs(tmp)
    1980     except IOError:
    1981         # Put in local directory instead, e.g., because user doesn't
    1982         # have privileges to write in Sage's tmp directory.  That's OK.
    1983         n = 0
    1984         while True:
    1985             tmp = "/temp/tmp_%s_%s"%(name, n)
    1986             if not os.path.exists(tmp):
    1987                 break
    1988             n += 1
    1989         os.makedirs(tmp)
    1990     return os.path.abspath(tmp)
    1991    
    1992 
    1993 #################################################################
    1994 # temporary filename
    1995 #################################################################
    1996 
    1997 __tmp_n = 0
    1998 
    1999 def tmp_filename(name='tmp'):
    2000     name = list(str(name))
    2001     for i in range(len(name)):
    2002         # protect against paths with slashes, colons, etc
    2003         if not (name[i].isalpha() or name[i].isdigit()):
    2004             name[i] = '_'
    2005     name = ''.join(name)
    2006 
    2007     global __tmp_n
    2008     while True:
    2009         tmp = "%s/%s_%s"%(SAGE_TMP, name, __tmp_n)
    2010         __tmp_n += 1
    2011         if not os.path.exists(tmp):
    2012             break
    2013     return tmp
    2014 
    20151938def graphics_filename(ext='png'):
    20161939    """
    20171940    Return the next available canonical filename for a plot/graphics
  • sage/misc/remote_file.py

    diff --git a/sage/misc/remote_file.py b/sage/misc/remote_file.py
    a b  
    1818    """
    1919    if verbose:
    2020        print "Attempting to load remote file: " + filename
    21     import misc
     21    import tempfiles as tmp
    2222   
    23     temp_name = misc.tmp_filename() + '.' + os.path.splitext(filename)[1][1:]
     23    temp_name = tmp.tmp_filename() + '.' + os.path.splitext(filename)[1][1:]
    2424    # IMPORTANT -- urllib takes a long time to load,
    2525    # so do not import it in the module scope.
    2626    import urllib
  • sage/misc/sagedoc.py

    diff --git a/sage/misc/sagedoc.py b/sage/misc/sagedoc.py
    a b  
    2525import os, re, sys
    2626import pydoc
    2727from sage.misc.viewer import browser
    28 from sage.misc.misc import SAGE_DOC, tmp_dir
     28from sage.misc.misc import SAGE_DOC
     29import tempfiles as tmp
    2930from sagenb.misc.sphinxify import sphinxify
    3031import sage.version
    3132
     
    12131214        if output == 'html':
    12141215            html = sphinxify(s)
    12151216            if view:
    1216                 path = os.path.join(tmp_dir(), "temp.html")
     1217                path = os.path.join(tmp.tmp_dir(), "temp.html")
    12171218                filed = open(path, 'w')
    12181219
    12191220                static_path = os.path.join(SAGE_DOC, 'output/html/en/_static')
  • sage/misc/sageinspect.py

    diff --git a/sage/misc/sageinspect.py b/sage/misc/sageinspect.py
    a b  
    14161416        source_lines = open(filename).readlines()
    14171417    except IOError:
    14181418        try:
    1419             from sage.all import SAGE_TMP
     1419            from sage.misc.tempfiles import SAGE_TMP
    14201420            raw_name = filename.split('/')[-1]
    14211421            newname = SAGE_TMP+'/spyx/'+'_'.join(raw_name.split('_')[:-1])+'/'+raw_name
    14221422            source_lines = open(newname).readlines()
  • new file sage/misc/tempfiles.py

    diff --git a/sage/misc/tempfiles.py b/sage/misc/tempfiles.py
    new file mode 100644
    - +  
     1
     2
     3from sage.misc.misc import DOT_SAGE, HOSTNAME, sage_makedirs
     4import os
     5
     6#################################################
     7# Next we create the Sage temporary directory.
     8# It is called temp instead of tmp mainly for
     9# "historical reasons"...
     10
     11SAGE_TMP='%s/temp/%s/%s/'%(DOT_SAGE, HOSTNAME, os.getpid())
     12sage_makedirs(SAGE_TMP)
     13SPYX_TMP = '%s/spyx/'%SAGE_TMP
     14
     15LOCAL_IDENTIFIER = '%s.%s'%(HOSTNAME , os.getpid())
     16
     17def delete_tmpfiles():
     18    # !!!If you change this, see also SAGE_ROOT/local/bin/sage-doctest!!!
     19    import shutil
     20    try:
     21        if os.path.exists(SAGE_TMP):
     22            shutil.rmtree(SAGE_TMP)
     23    except OSError, msg:
     24        print msg
     25        pass
     26
     27SAGE_TMP_INTERFACE='%s/interface/'%SAGE_TMP
     28sage_makedirs(SAGE_TMP_INTERFACE)
     29
     30#################################################################
     31# temporary directory
     32#################################################################
     33
     34def tmp_dir(name='dir'):
     35    r"""
     36    Create and return a temporary directory in
     37    ``$HOME/.sage/temp/hostname/pid/``
     38    """
     39    name = str(name)
     40    n = 0
     41    while True:
     42        tmp = "%s/%s_%s"%(SAGE_TMP, name, n)
     43        if not os.path.exists(tmp):
     44            break
     45        n += 1
     46    try:
     47        os.makedirs(tmp)
     48    except IOError:
     49        # Put in local directory instead, e.g., because user doesn't
     50        # have privileges to write in Sage's tmp directory.  That's OK.
     51        n = 0
     52        while True:
     53            tmp = "/temp/tmp_%s_%s"%(name, n)
     54            if not os.path.exists(tmp):
     55                break
     56            n += 1
     57        os.makedirs(tmp)
     58    return os.path.abspath(tmp)
     59   
     60
     61#################################################################
     62# temporary filename
     63#################################################################
     64
     65__tmp_n = 0
     66
     67def tmp_filename(name='tmp'):
     68    name = list(str(name))
     69    for i in range(len(name)):
     70        # protect against paths with slashes, colons, etc
     71        if not (name[i].isalpha() or name[i].isdigit()):
     72            name[i] = '_'
     73    name = ''.join(name)
     74
     75    global __tmp_n
     76    while True:
     77        tmp = "%s/%s_%s"%(SAGE_TMP, name, __tmp_n)
     78        __tmp_n += 1
     79        if not os.path.exists(tmp):
     80            break
     81    return tmp
     82
  • sage/parallel/use_fork.py

    diff --git a/sage/parallel/use_fork.py b/sage/parallel/use_fork.py
    a b  
    8484        v = list(inputs)
    8585        import os, sys, signal
    8686        from sage.structure.sage_object import load
    87         from sage.misc.misc import tmp_dir, walltime
     87        from sage.misc.misc import walltime
     88        from sage.misc.tempfiles import tmp_dir
    8889        dir = tmp_dir()
    8990        timeout = self.timeout
    9091        # Subprocesses shouldn't inherit unflushed buffers (cf. #11778):
  • sage/plot/animate.py

    diff --git a/sage/plot/animate.py b/sage/plot/animate.py
    a b  
    2020from sage.structure.sage_object import SageObject
    2121
    2222import plot
     23import sage.misc.tempfiles as tmp
    2324import sage.misc.misc
    2425import sage.misc.viewer
    2526
     
    257258            return self.__png_dir
    258259        except AttributeError:
    259260            pass
    260         d = sage.misc.misc.tmp_dir()
     261        d = tmp.tmp_dir()
    261262        G = self.__frames
    262263        for i, frame in enumerate(self.__frames):
    263264            filename = '%s/%s'%(d,sage.misc.misc.pad_zeros(i,8))
     
    454455              See www.imagemagick.org and www.ffmpeg.org for more information.
    455456        """
    456457        if plot.DOCTEST_MODE:
    457             filename = sage.misc.misc.tmp_filename() + '.gif'
     458            filename = tmp.tmp_filename() + '.gif'
    458459            self.gif(savefile=filename, delay=delay, iterations=iterations)
    459460            return
    460461       
    461462        if plot.EMBEDDED_MODE:
    462463            self.gif(delay = delay, iterations = iterations)
    463464        else:
    464             filename = sage.misc.misc.tmp_filename() + '.gif'
     465            filename = tmp.tmp_filename() + '.gif'
    465466            self.gif(delay=delay, savefile=filename, iterations=iterations)
    466467            os.system('%s %s 2>/dev/null 1>/dev/null &'%(
    467468                sage.misc.viewer.browser(), filename))
  • sage/plot/plot.py

    diff --git a/sage/plot/plot.py b/sage/plot/plot.py
    a b  
    333333EMBEDDED_MODE = False
    334334DOCTEST_MODE = False
    335335import sage.misc.misc
     336import sage.misc.tempfiles as tmp
    336337from sage.misc.misc import srange
    337 DOCTEST_MODE_FILE = os.path.join(sage.misc.misc.SAGE_TMP, 'test.png')
    338338SHOW_DEFAULT = True
    339339
    340340def show_default(default=None):
     
    17791779
    17801780        if DOCTEST_MODE:
    17811781            kwds.pop('filename', None)
     1782            DOCTEST_MODE_FILE = os.path.join(tmp.SAGE_TMP, 'test.png')
    17821783            self.save(DOCTEST_MODE_FILE, **kwds)
    17831784        elif EMBEDDED_MODE:
    17841785            kwds.setdefault('filename', sage.misc.misc.graphics_filename())
     
    17881789            else:
    17891790                html("<img src='cell://%s'>" % kwds['filename'])
    17901791        else:
    1791             kwds.setdefault('filename', sage.misc.misc.tmp_filename() + '.png')
     1792            kwds.setdefault('filename', tmp.tmp_filename() + '.png')
    17921793            self.save(**kwds)
    17931794            os.system('%s %s 2>/dev/null 1>/dev/null &'
    17941795                      % (sage.misc.viewer.browser(), kwds['filename']))
     
    24582459        You can also pass extra options to the plot command instead of this
    24592460        method, e.g. ::
    24602461       
    2461             sage: plot(x^2 - 5, (x, 0, 5), ymin=0).save(
    2462             ...       sage.misc.misc.tmp_filename() + '.png')
     2462            sage: plot(x^2 - 5, (x, 0, 5), ymin=0).save(tmp_filename() + '.png')
    24632463           
    24642464        will save the same plot as the one shown by this command::
    24652465       
     
    41414141        """
    41424142        if (figsize is not None): self.__set_figsize__(figsize)
    41434143        if DOCTEST_MODE:
     4144            DOCTEST_MODE_FILE = os.path.join(tmp.SAGE_TMP, 'test.png')
    41444145            self.save(DOCTEST_MODE_FILE,
    41454146                      dpi=dpi, figsize=self._figsize, axes = axes, **args)
    41464147            return
  • sage/plot/plot3d/base.pyx

    diff --git a/sage/plot/plot3d/base.pyx b/sage/plot/plot3d/base.pyx
    a b  
    3636import zipfile
    3737from cStringIO import StringIO
    3838
    39 import sage.misc.misc
     39import sage.misc.tempfiles as tmp
    4040
    4141from sage.modules.free_module_element import vector
    4242
     
    564564
    565565        EXAMPLES::
    566566
    567             sage: out_file = sage.misc.misc.tmp_filename() + ".jmol"
     567            sage: out_file = tmp_filename() + ".jmol"
    568568            sage: G = sphere((1, 2, 3), 5) + cube() + sage.plot.plot3d.shapes.Text("hi")
    569569            sage: G.export_jmol(out_file)
    570570            sage: import zipfile
     
    10731073            filename = kwds['filename']
    10741074            del kwds['filename']
    10751075        else:
    1076             filename = sage.misc.misc.tmp_filename()
     1076            filename = tmp.tmp_filename()
    10771077
    10781078        from sage.plot.plot import EMBEDDED_MODE, DOCTEST_MODE
    10791079        ext = None
     
    10811081        # Tachyon resolution options
    10821082        if DOCTEST_MODE:
    10831083            opts = '-res 10 10'
    1084             filename = sage.misc.misc.SAGE_TMP + "/tmp"
     1084            filename = tmp.SAGE_TMP + "/tmp"
    10851085        elif EMBEDDED_MODE:
    10861086            opts = '-res %s %s'%(figsize[0]*100, figsize[1]*100)
    10871087            filename = sage.misc.misc.graphics_filename()[:-4]
     
    12021202                out_filename = filename
    12031203            else:
    12041204                # Save to a temporary file, and then convert using PIL
    1205                 out_filename = sage.misc.misc.tmp_filename()
     1205                out_filename = tmp.tmp_filename()
    12061206            tachyon_rt(T.tachyon(), out_filename, opts['verbosity'], True,
    12071207                '-res %s %s' % (opts['figsize'][0]*100, opts['figsize'][1]*100))
    12081208            if ext != 'png':
     
    19041904            sage: params.foo
    19051905            'x'
    19061906        """
    1907         self.output_file = sage.misc.misc.tmp_filename()
     1907        self.output_file = tmp.tmp_filename()
    19081908        self.obj_vertex_offset = 1
    19091909        self.transform_list = []
    19101910        self.transform = None
     
    20262026    cdef Py_ssize_t i = 0
    20272027    while i < PyList_GET_SIZE(L) or PyList_GET_SIZE(L_stack) > 0:
    20282028        while i < PyList_GET_SIZE(L):
    2029             tmp = <object>PyList_GET_ITEM(L, i)
    2030             if PyList_CheckExact(tmp):
     2029            temp = <object>PyList_GET_ITEM(L, i)
     2030            if PyList_CheckExact(temp):
    20312031                PyList_Append(L_stack, L)
    2032                 L = tmp
     2032                L = temp
    20332033                PyList_Append(i_stack, i)
    20342034                i = 0
    20352035            else:
    2036                 PyList_Append(flat, tmp)
     2036                PyList_Append(flat, temp)
    20372037                i += 1
    20382038        if PyList_GET_SIZE(L_stack) > 0:
    20392039            L = L_pop()
  • sage/plot/plot3d/tachyon.py

    diff --git a/sage/plot/plot3d/tachyon.py b/sage/plot/plot3d/tachyon.py
    a b  
    5454
    5555from sage.structure.sage_object import SageObject
    5656
    57 from sage.misc.misc import SAGE_TMP
     57import sage.misc.tempfiles as tmp
    5858
    5959#from sage.ext import fast_tachyon_routines
    6060
     
    313313        import sage.plot.plot
    314314        if sage.plot.plot.DOCTEST_MODE:
    315315            filename = sage.misc.misc.graphics_filename()
    316             self.save(SAGE_TMP + '/test.png', verbose=verbose, extra_opts=extra_opts)
     316            self.save(tmp.SAGE_TMP + '/test.png', verbose=verbose, extra_opts=extra_opts)
    317317            return
    318318        if sage.plot.plot.EMBEDDED_MODE:
    319319            filename = sage.misc.misc.graphics_filename()
    320320            self.save(filename, verbose=verbose, extra_opts=extra_opts)
    321321            return
    322         filename = sage.misc.misc.tmp_filename() + '.png'
     322        filename = tmp.tmp_filename() + '.png'
    323323        self.save(filename, verbose=verbose, extra_opts=extra_opts)
    324324        os.system('%s %s 2>/dev/null 1>/dev/null &'%(sage.misc.viewer.browser(), filename))
    325325
  • sage/rings/number_field/totallyreal_phc.py

    diff --git a/sage/rings/number_field/totallyreal_phc.py b/sage/rings/number_field/totallyreal_phc.py
    a b  
    2121#                  http://www.gnu.org/licenses/
    2222#*****************************************************************************
    2323
    24 import sage.misc.misc
     24import sage.misc.tempfiles as tmp
    2525
    2626def coefficients_to_power_sums(n, m, a):
    2727    r"""
     
    109109
    110110    # Initialization.
    111111    if tmpfile is None:
    112         tmpfile = sage.misc.misc.tmp_filename()
     112        tmpfile = tmp.tmp_filename()
    113113    f = open(tmpfile + '.phc', 'w')
    114114    f.close()
    115115    x = [0]*m
  • sage/sandpiles/sandpile.py

    diff --git a/sage/sandpiles/sandpile.py b/sage/sandpiles/sandpile.py
    a b  
    55from sage.graphs.all import DiGraph, Graph, graphs, digraphs
    66from copy import deepcopy
    77from sage.rings.all import PolynomialRing, QQ, ZZ, lcm
    8 from sage.misc.all import prod, det, forall, tmp_filename, random, randint, exists, denominator, srange
     8from sage.misc.all import prod, det, forall, random, randint, exists, denominator, srange
    99from sage.misc.misc import deprecated_function_alias
    1010from sage.modules.free_module_element import vector
    1111from sage.matrix.constructor import matrix, identity_matrix
     
    40514051        n = self._sandpile.num_verts()
    40524052
    40534053        # temporary file names
     4054        from sage.misc.tempfiles import tmp_filename
    40544055        lin_sys = tmp_filename()
    40554056        lin_sys_mat = lin_sys + '.mat'
    40564057        lin_sys_rel = lin_sys + '.rel'
  • sage/structure/sage_object.pyx

    diff --git a/sage/structure/sage_object.pyx b/sage/structure/sage_object.pyx
    a b  
    11411141    # This could use instead Python's tarfile module
    11421142    if dir.endswith('.tar.bz2'):
    11431143        # create a temporary directory
    1144         from sage.misc.all import tmp_dir
     1144        from sage.misc.tempfiles import tmp_dir
    11451145        T = tmp_dir()
    11461146        # extract tarball to it
    11471147        os.system('cd "%s"; bunzip2 -c "%s" | tar fx - '%(T, os.path.abspath(dir)))