ysharma HF Staff commited on
Commit
f42f0bd
·
verified ·
1 Parent(s): 770c132

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -26
app.py CHANGED
@@ -9,6 +9,19 @@ import random
9
  import string
10
  import glob
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  def create_local():
13
  length = 100
14
  text_string = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(length))
@@ -23,7 +36,7 @@ def movefiles():
23
  # Get the path of the system's temporary directory
24
  temp_directory = tempfile.gettempdir()
25
 
26
- # Specify the path of the file you want to move
27
  directory_name = 'temp_dir'
28
  absolute_path = os.path.abspath(directory_name)
29
  file_path = 'random_file_1.txt'
@@ -40,25 +53,6 @@ def movefiles():
40
  print(f"Moved the file to: {new_path}")
41
 
42
 
43
- # Assuming 'my_directory' is a directory in the current working directory
44
- directory_name = 'temp_dir'
45
- absolute_path1 = os.path.abspath(directory_name)
46
- #print(f"The absolute path of '{directory_name}' is: {absolute_path1}")
47
- #/home/user/app/temp_dir
48
-
49
- # Access the environment variable
50
- os.environ['GRADIO_TEMP_DIR'] = '/data'
51
- gradio_temp_dir = os.environ['GRADIO_TEMP_DIR']
52
- print(f'GRADIO_TEMP_DIR is = {gradio_temp_dir}')
53
- absolute_path1 = os.path.abspath(gradio_temp_dir)
54
- print(f"The absolute path of gradio_temp_dir is = {absolute_path1}")
55
-
56
-
57
- # Get the path of the system's temporary directory
58
- temp_directory = tempfile.gettempdir()
59
- print(f"System's temporary directory is: {temp_directory}")
60
-
61
-
62
  def create():
63
  """
64
  Create a blank image with the specified dimensions, color, and filename.
@@ -69,18 +63,12 @@ def create():
69
  # Create a temporary file
70
  temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".png")
71
  print(f"Temporary file created at: {temp_file.name}")
72
- #filename = f'{temp_file.name}.png'
73
  # Create a new image with the given mode and size
74
  image = Image.new("RGB", (width, height), color)
75
  # Save the image to disk
76
  image.save(temp_file, format='PNG')
77
 
78
-
79
- # Specify the directory you want to search in, e.g., the current directory
80
- directory = 'temp_dir'
81
  # List all entries in the directory
82
- entries = os.listdir(directory)
83
- #print(f"listdir of temp_dir directory = {entries}")
84
  temp_directory_file_list = os.listdir(temp_directory)
85
  print(f'temp_directory_file_list is = {temp_directory_file_list}')
86
  return temp_file.name, temp_directory_file_list
 
9
  import string
10
  import glob
11
 
12
+
13
+ # Set the environment variable
14
+ os.environ['GRADIO_TEMP_DIR'] = '/data'
15
+ gradio_temp_dir = os.environ['GRADIO_TEMP_DIR']
16
+
17
+ #print(f'GRADIO_TEMP_DIR is = {gradio_temp_dir}')
18
+ #absolute_path1 = os.path.abspath(gradio_temp_dir)
19
+ #print(f"The absolute path of gradio_temp_dir is = {absolute_path1}")
20
+
21
+ # Get the path of the system's temporary directory
22
+ temp_directory = tempfile.gettempdir()
23
+ print(f"System's temporary directory is: {temp_directory}")
24
+
25
  def create_local():
26
  length = 100
27
  text_string = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(length))
 
36
  # Get the path of the system's temporary directory
37
  temp_directory = tempfile.gettempdir()
38
 
39
+ # Specify the path of the file to be moved
40
  directory_name = 'temp_dir'
41
  absolute_path = os.path.abspath(directory_name)
42
  file_path = 'random_file_1.txt'
 
53
  print(f"Moved the file to: {new_path}")
54
 
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  def create():
57
  """
58
  Create a blank image with the specified dimensions, color, and filename.
 
63
  # Create a temporary file
64
  temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".png")
65
  print(f"Temporary file created at: {temp_file.name}")
 
66
  # Create a new image with the given mode and size
67
  image = Image.new("RGB", (width, height), color)
68
  # Save the image to disk
69
  image.save(temp_file, format='PNG')
70
 
 
 
 
71
  # List all entries in the directory
 
 
72
  temp_directory_file_list = os.listdir(temp_directory)
73
  print(f'temp_directory_file_list is = {temp_directory_file_list}')
74
  return temp_file.name, temp_directory_file_list