SlideShare a Scribd company logo
1 of 5
Download to read offline
My mkdir command /create_directory command always deletes all the files and doesnt really
create the directory for some reason but my create_file function does. How can I fix this?
screenshot of code:
code transcript
import sys
import json
import requests
import base64
# Firebase URL
firebase_url = "url"
# Function to get the data from Firebase
def get_firebase_data(url):
response = requests.get(url)
data = json.loads(response.text)
return data
# Function to list all files and directories under a given directory
def list_directory(dir_path):
data = get_firebase_data(firebase_url + dir_path + ".json")
if isinstance(data, dict):
for key in data.keys():
if key == "content":
print(dir_path + ": " + data[key])
else:
list_directory(dir_path + "/" + key)
# Function to create a new file with the given content
def create_file(file_path, content):
data = {"content": content}
response = requests.put(firebase_url + file_path + ".json", data=json.dumps(data))
if response.status_code == 200:
print("File created successfully")
elif response.status_code == 400:
print("File already exists")
# Function to create a new directory
def create_directory(dir_path):
data = {}
response = requests.put(firebase_url + dir_path + ".json", data=json.dumps(data))
if response.status_code == 200:
print("Directory created successfully")
elif response.status_code == 400:
print("Directory already exists")
# Function to remove a file or directory
def remove(path):
response = requests.delete(firebase_url + path + ".json")
if response.status_code == 200:
print("File/directory removed successfully")
elif response.status_code == 404:
print("File/directory not found")
# Function to export the file system structure in XML format
def export_xml():
root_data = get_firebase_data(firebase_url + ".json")
print("<root>")
for key in root_data.keys():
print("<" + key + ">")
export_directory(key)
print("</" + key + ">")
print("</root>")
# Function to export a directory and its contents in XML format
def export_directory(dir_path):
data = get_firebase_data(firebase_url + dir_path + ".json")
if isinstance(data, dict):
for key in data.keys():
if key == "content":
content = data[key]
print("<file name='" + dir_path + "'>" + base64.b64encode(content.encode('utf-8')).decode('utf-
8') + "</file>")
else:
print("<directory name='" + key + "'>")
export_directory(dir_path + "/" + key)
print("</directory>")
# Parse the command-line arguments
args = sys.argv
if len(args) < 3:
print("Usage: python3 edfs.py <command> <path> [content]")
exit()
command = args[1]
x= args[2].split('/')
content = x[-1]
del x[-1]
path='/'.join(x)
print(path)
# Use the extracted path and file name as needed
if command == "-create":
if len(args) < 2:
print("Usage: python3 edfs.py -create <path> <content>")
exit()
create_file(path, content)
elif command == "-mkdir":
create_directory(path)
elif command == "-rmdir" or command == "-rm":
remove(path)
elif command == "-ls":
list_directory(path)
elif command == "-export":
export_xml()
else:
print("Invalid command: " + command)
print("Usage: python3 edfs.py <command> <path> [content]")

More Related Content

Similar to My mkdir command -create_directory command always deletes all the file.pdf

Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRick Copeland
 
Edit the script in to disable code which adds demonstration entries to.pdf
Edit the script in to disable code which adds demonstration entries to.pdfEdit the script in to disable code which adds demonstration entries to.pdf
Edit the script in to disable code which adds demonstration entries to.pdfPeterM9sWhitej
 
Dpilot Source Code With ScreenShots
Dpilot Source Code With ScreenShots Dpilot Source Code With ScreenShots
Dpilot Source Code With ScreenShots DeepAnshu Sharma
 
Dpilot - Source Code with Snapshots
Dpilot - Source Code with SnapshotsDpilot - Source Code with Snapshots
Dpilot - Source Code with SnapshotsKritika Phulli
 
Source Code for Dpilot
Source Code for Dpilot Source Code for Dpilot
Source Code for Dpilot Nidhi Chauhan
 
Secure PHP Coding - Part 1
Secure PHP Coding - Part 1Secure PHP Coding - Part 1
Secure PHP Coding - Part 1Vinoth Kumar
 
CoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairCoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairMark
 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappersPositive Hack Days
 
What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?Alexandru Badiu
 
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationCodeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationAbdul Malik Ikhsan
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 WorldFabien Potencier
 
Python - File operations & Data parsing
Python - File operations & Data parsingPython - File operations & Data parsing
Python - File operations & Data parsingFelix Z. Hoffmann
 
Webmontag Berlin "coffee script"
Webmontag Berlin "coffee script"Webmontag Berlin "coffee script"
Webmontag Berlin "coffee script"Webmontag Berlin
 
Creating Domain Specific Languages in Python
Creating Domain Specific Languages in PythonCreating Domain Specific Languages in Python
Creating Domain Specific Languages in PythonSiddhi
 
Practical Google App Engine Applications In Py
Practical Google App Engine Applications In PyPractical Google App Engine Applications In Py
Practical Google App Engine Applications In PyEric ShangKuan
 
File upload for the 21st century
File upload for the 21st centuryFile upload for the 21st century
File upload for the 21st centuryJiří Pudil
 

Similar to My mkdir command -create_directory command always deletes all the file.pdf (20)

Rapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and MingRapid and Scalable Development with MongoDB, PyMongo, and Ming
Rapid and Scalable Development with MongoDB, PyMongo, and Ming
 
My First Ruby
My First RubyMy First Ruby
My First Ruby
 
Edit the script in to disable code which adds demonstration entries to.pdf
Edit the script in to disable code which adds demonstration entries to.pdfEdit the script in to disable code which adds demonstration entries to.pdf
Edit the script in to disable code which adds demonstration entries to.pdf
 
Dpilot Source Code With ScreenShots
Dpilot Source Code With ScreenShots Dpilot Source Code With ScreenShots
Dpilot Source Code With ScreenShots
 
Dpilot - Source Code with Snapshots
Dpilot - Source Code with SnapshotsDpilot - Source Code with Snapshots
Dpilot - Source Code with Snapshots
 
Source Code for Dpilot
Source Code for Dpilot Source Code for Dpilot
Source Code for Dpilot
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
 
Secure PHP Coding - Part 1
Secure PHP Coding - Part 1Secure PHP Coding - Part 1
Secure PHP Coding - Part 1
 
CoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love AffairCoffeeScript - A Rubyist's Love Affair
CoffeeScript - A Rubyist's Love Affair
 
On secure application of PHP wrappers
On secure application  of PHP wrappersOn secure application  of PHP wrappers
On secure application of PHP wrappers
 
What's new in the Drupal 7 API?
What's new in the Drupal 7 API?What's new in the Drupal 7 API?
What's new in the Drupal 7 API?
 
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationCodeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept Implementation
 
News of the Symfony2 World
News of the Symfony2 WorldNews of the Symfony2 World
News of the Symfony2 World
 
Python - File operations & Data parsing
Python - File operations & Data parsingPython - File operations & Data parsing
Python - File operations & Data parsing
 
Webmontag Berlin "coffee script"
Webmontag Berlin "coffee script"Webmontag Berlin "coffee script"
Webmontag Berlin "coffee script"
 
Doctrine and NoSQL
Doctrine and NoSQLDoctrine and NoSQL
Doctrine and NoSQL
 
Creating Domain Specific Languages in Python
Creating Domain Specific Languages in PythonCreating Domain Specific Languages in Python
Creating Domain Specific Languages in Python
 
SphinxSE with MySQL
SphinxSE with MySQLSphinxSE with MySQL
SphinxSE with MySQL
 
Practical Google App Engine Applications In Py
Practical Google App Engine Applications In PyPractical Google App Engine Applications In Py
Practical Google App Engine Applications In Py
 
File upload for the 21st century
File upload for the 21st centuryFile upload for the 21st century
File upload for the 21st century
 

More from Robert4vCParsonsn

Name - Rakib Mia Age - 22 Educational Qualification - Class 7 Professi.pdf
Name - Rakib Mia Age - 22 Educational Qualification - Class 7 Professi.pdfName - Rakib Mia Age - 22 Educational Qualification - Class 7 Professi.pdf
Name - Rakib Mia Age - 22 Educational Qualification - Class 7 Professi.pdfRobert4vCParsonsn
 
Name of the Project- Implementation of a debit card service (1) List a.pdf
Name of the Project- Implementation of a debit card service (1) List a.pdfName of the Project- Implementation of a debit card service (1) List a.pdf
Name of the Project- Implementation of a debit card service (1) List a.pdfRobert4vCParsonsn
 
Multicellular organisms with a true nucleus- histone proteins- ester-l.pdf
Multicellular organisms with a true nucleus- histone proteins- ester-l.pdfMulticellular organisms with a true nucleus- histone proteins- ester-l.pdf
Multicellular organisms with a true nucleus- histone proteins- ester-l.pdfRobert4vCParsonsn
 
Mulaple choice- answer all questions- (1 point each) 3- Which of the f.pdf
Mulaple choice- answer all questions- (1 point each) 3- Which of the f.pdfMulaple choice- answer all questions- (1 point each) 3- Which of the f.pdf
Mulaple choice- answer all questions- (1 point each) 3- Which of the f.pdfRobert4vCParsonsn
 
Mr Ahmad is a 65-year-old male who was admitted to the medical ward as (1).pdf
Mr Ahmad is a 65-year-old male who was admitted to the medical ward as (1).pdfMr Ahmad is a 65-year-old male who was admitted to the medical ward as (1).pdf
Mr Ahmad is a 65-year-old male who was admitted to the medical ward as (1).pdfRobert4vCParsonsn
 
Mr Ahmad is a 65-year-old male who was admitted to the medical ward as.pdf
Mr Ahmad is a 65-year-old male who was admitted to the medical ward as.pdfMr Ahmad is a 65-year-old male who was admitted to the medical ward as.pdf
Mr Ahmad is a 65-year-old male who was admitted to the medical ward as.pdfRobert4vCParsonsn
 
Mr- and Mrs- Kim Soo use a fiscal year ending July 31 as the taxable y.pdf
Mr- and Mrs- Kim Soo use a fiscal year ending July 31 as the taxable y.pdfMr- and Mrs- Kim Soo use a fiscal year ending July 31 as the taxable y.pdf
Mr- and Mrs- Kim Soo use a fiscal year ending July 31 as the taxable y.pdfRobert4vCParsonsn
 
mother delivers a baby that has neonatal drug withdrawal- When talking.pdf
mother delivers a baby that has neonatal drug withdrawal- When talking.pdfmother delivers a baby that has neonatal drug withdrawal- When talking.pdf
mother delivers a baby that has neonatal drug withdrawal- When talking.pdfRobert4vCParsonsn
 
Most of the cells in the body carry receptors for the insulin hormone.pdf
Most of the cells in the body carry receptors for the insulin hormone.pdfMost of the cells in the body carry receptors for the insulin hormone.pdf
Most of the cells in the body carry receptors for the insulin hormone.pdfRobert4vCParsonsn
 
Monty Corp- Inc- had a beginning inventory of 100 units of Product RST (1).pdf
Monty Corp- Inc- had a beginning inventory of 100 units of Product RST (1).pdfMonty Corp- Inc- had a beginning inventory of 100 units of Product RST (1).pdf
Monty Corp- Inc- had a beginning inventory of 100 units of Product RST (1).pdfRobert4vCParsonsn
 
Modular bilis are used to reduce the number of 80M s when a product co.pdf
Modular bilis are used to reduce the number of 80M s when a product co.pdfModular bilis are used to reduce the number of 80M s when a product co.pdf
Modular bilis are used to reduce the number of 80M s when a product co.pdfRobert4vCParsonsn
 
Modern corporations have always dominated the U-S- economy--going all.pdf
Modern corporations have always dominated the U-S- economy--going all.pdfModern corporations have always dominated the U-S- economy--going all.pdf
Modern corporations have always dominated the U-S- economy--going all.pdfRobert4vCParsonsn
 
Missing Node while Printing a Sorted List (C) I have a linked list t.pdf
Missing Node while Printing a Sorted List (C)   I have a linked list t.pdfMissing Node while Printing a Sorted List (C)   I have a linked list t.pdf
Missing Node while Printing a Sorted List (C) I have a linked list t.pdfRobert4vCParsonsn
 
Mod 8 Network Layer Worksheet IPv4 hosts have a routing table they use.pdf
Mod 8 Network Layer Worksheet IPv4 hosts have a routing table they use.pdfMod 8 Network Layer Worksheet IPv4 hosts have a routing table they use.pdf
Mod 8 Network Layer Worksheet IPv4 hosts have a routing table they use.pdfRobert4vCParsonsn
 
Mimite Vaso What target market did Applebee's pursue in its recent ove.pdf
Mimite Vaso What target market did Applebee's pursue in its recent ove.pdfMimite Vaso What target market did Applebee's pursue in its recent ove.pdf
Mimite Vaso What target market did Applebee's pursue in its recent ove.pdfRobert4vCParsonsn
 
Merge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.pdf
Merge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.pdfMerge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.pdf
Merge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.pdfRobert4vCParsonsn
 
menu' is very easily copied and is not a good soutce of custained adva.pdf
menu' is very easily copied and is not a good soutce of custained adva.pdfmenu' is very easily copied and is not a good soutce of custained adva.pdf
menu' is very easily copied and is not a good soutce of custained adva.pdfRobert4vCParsonsn
 
Mark all the statements that are correct regarding the image shown bel.pdf
Mark all the statements that are correct regarding the image shown bel.pdfMark all the statements that are correct regarding the image shown bel.pdf
Mark all the statements that are correct regarding the image shown bel.pdfRobert4vCParsonsn
 
Media literacy is an important 21st-century skill- For this discussion.pdf
Media literacy is an important 21st-century skill- For this discussion.pdfMedia literacy is an important 21st-century skill- For this discussion.pdf
Media literacy is an important 21st-century skill- For this discussion.pdfRobert4vCParsonsn
 
Mel and Jan own a ranch in Wyoming as joint tenants- If Jan dies from.pdf
Mel and Jan own a ranch in Wyoming as joint tenants-  If Jan dies from.pdfMel and Jan own a ranch in Wyoming as joint tenants-  If Jan dies from.pdf
Mel and Jan own a ranch in Wyoming as joint tenants- If Jan dies from.pdfRobert4vCParsonsn
 

More from Robert4vCParsonsn (20)

Name - Rakib Mia Age - 22 Educational Qualification - Class 7 Professi.pdf
Name - Rakib Mia Age - 22 Educational Qualification - Class 7 Professi.pdfName - Rakib Mia Age - 22 Educational Qualification - Class 7 Professi.pdf
Name - Rakib Mia Age - 22 Educational Qualification - Class 7 Professi.pdf
 
Name of the Project- Implementation of a debit card service (1) List a.pdf
Name of the Project- Implementation of a debit card service (1) List a.pdfName of the Project- Implementation of a debit card service (1) List a.pdf
Name of the Project- Implementation of a debit card service (1) List a.pdf
 
Multicellular organisms with a true nucleus- histone proteins- ester-l.pdf
Multicellular organisms with a true nucleus- histone proteins- ester-l.pdfMulticellular organisms with a true nucleus- histone proteins- ester-l.pdf
Multicellular organisms with a true nucleus- histone proteins- ester-l.pdf
 
Mulaple choice- answer all questions- (1 point each) 3- Which of the f.pdf
Mulaple choice- answer all questions- (1 point each) 3- Which of the f.pdfMulaple choice- answer all questions- (1 point each) 3- Which of the f.pdf
Mulaple choice- answer all questions- (1 point each) 3- Which of the f.pdf
 
Mr Ahmad is a 65-year-old male who was admitted to the medical ward as (1).pdf
Mr Ahmad is a 65-year-old male who was admitted to the medical ward as (1).pdfMr Ahmad is a 65-year-old male who was admitted to the medical ward as (1).pdf
Mr Ahmad is a 65-year-old male who was admitted to the medical ward as (1).pdf
 
Mr Ahmad is a 65-year-old male who was admitted to the medical ward as.pdf
Mr Ahmad is a 65-year-old male who was admitted to the medical ward as.pdfMr Ahmad is a 65-year-old male who was admitted to the medical ward as.pdf
Mr Ahmad is a 65-year-old male who was admitted to the medical ward as.pdf
 
Mr- and Mrs- Kim Soo use a fiscal year ending July 31 as the taxable y.pdf
Mr- and Mrs- Kim Soo use a fiscal year ending July 31 as the taxable y.pdfMr- and Mrs- Kim Soo use a fiscal year ending July 31 as the taxable y.pdf
Mr- and Mrs- Kim Soo use a fiscal year ending July 31 as the taxable y.pdf
 
mother delivers a baby that has neonatal drug withdrawal- When talking.pdf
mother delivers a baby that has neonatal drug withdrawal- When talking.pdfmother delivers a baby that has neonatal drug withdrawal- When talking.pdf
mother delivers a baby that has neonatal drug withdrawal- When talking.pdf
 
Most of the cells in the body carry receptors for the insulin hormone.pdf
Most of the cells in the body carry receptors for the insulin hormone.pdfMost of the cells in the body carry receptors for the insulin hormone.pdf
Most of the cells in the body carry receptors for the insulin hormone.pdf
 
Monty Corp- Inc- had a beginning inventory of 100 units of Product RST (1).pdf
Monty Corp- Inc- had a beginning inventory of 100 units of Product RST (1).pdfMonty Corp- Inc- had a beginning inventory of 100 units of Product RST (1).pdf
Monty Corp- Inc- had a beginning inventory of 100 units of Product RST (1).pdf
 
Modular bilis are used to reduce the number of 80M s when a product co.pdf
Modular bilis are used to reduce the number of 80M s when a product co.pdfModular bilis are used to reduce the number of 80M s when a product co.pdf
Modular bilis are used to reduce the number of 80M s when a product co.pdf
 
Modern corporations have always dominated the U-S- economy--going all.pdf
Modern corporations have always dominated the U-S- economy--going all.pdfModern corporations have always dominated the U-S- economy--going all.pdf
Modern corporations have always dominated the U-S- economy--going all.pdf
 
Missing Node while Printing a Sorted List (C) I have a linked list t.pdf
Missing Node while Printing a Sorted List (C)   I have a linked list t.pdfMissing Node while Printing a Sorted List (C)   I have a linked list t.pdf
Missing Node while Printing a Sorted List (C) I have a linked list t.pdf
 
Mod 8 Network Layer Worksheet IPv4 hosts have a routing table they use.pdf
Mod 8 Network Layer Worksheet IPv4 hosts have a routing table they use.pdfMod 8 Network Layer Worksheet IPv4 hosts have a routing table they use.pdf
Mod 8 Network Layer Worksheet IPv4 hosts have a routing table they use.pdf
 
Mimite Vaso What target market did Applebee's pursue in its recent ove.pdf
Mimite Vaso What target market did Applebee's pursue in its recent ove.pdfMimite Vaso What target market did Applebee's pursue in its recent ove.pdf
Mimite Vaso What target market did Applebee's pursue in its recent ove.pdf
 
Merge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.pdf
Merge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.pdfMerge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.pdf
Merge(numbers- 0-2-5) is called- Complete the table for leftPos and ri.pdf
 
menu' is very easily copied and is not a good soutce of custained adva.pdf
menu' is very easily copied and is not a good soutce of custained adva.pdfmenu' is very easily copied and is not a good soutce of custained adva.pdf
menu' is very easily copied and is not a good soutce of custained adva.pdf
 
Mark all the statements that are correct regarding the image shown bel.pdf
Mark all the statements that are correct regarding the image shown bel.pdfMark all the statements that are correct regarding the image shown bel.pdf
Mark all the statements that are correct regarding the image shown bel.pdf
 
Media literacy is an important 21st-century skill- For this discussion.pdf
Media literacy is an important 21st-century skill- For this discussion.pdfMedia literacy is an important 21st-century skill- For this discussion.pdf
Media literacy is an important 21st-century skill- For this discussion.pdf
 
Mel and Jan own a ranch in Wyoming as joint tenants- If Jan dies from.pdf
Mel and Jan own a ranch in Wyoming as joint tenants-  If Jan dies from.pdfMel and Jan own a ranch in Wyoming as joint tenants-  If Jan dies from.pdf
Mel and Jan own a ranch in Wyoming as joint tenants- If Jan dies from.pdf
 

Recently uploaded

Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppCeline George
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽中 央社
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjMohammed Sikander
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...Nguyen Thanh Tu Collection
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxCeline George
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
An Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge AppAn Overview of the Odoo 17 Knowledge App
An Overview of the Odoo 17 Knowledge App
 
Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"Mattingly "AI & Prompt Design: Named Entity Recognition"
Mattingly "AI & Prompt Design: Named Entity Recognition"
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 

My mkdir command -create_directory command always deletes all the file.pdf

  • 1. My mkdir command /create_directory command always deletes all the files and doesnt really create the directory for some reason but my create_file function does. How can I fix this? screenshot of code: code transcript import sys import json import requests import base64 # Firebase URL firebase_url = "url" # Function to get the data from Firebase def get_firebase_data(url): response = requests.get(url) data = json.loads(response.text) return data # Function to list all files and directories under a given directory def list_directory(dir_path): data = get_firebase_data(firebase_url + dir_path + ".json") if isinstance(data, dict): for key in data.keys(): if key == "content": print(dir_path + ": " + data[key]) else:
  • 2. list_directory(dir_path + "/" + key) # Function to create a new file with the given content def create_file(file_path, content): data = {"content": content} response = requests.put(firebase_url + file_path + ".json", data=json.dumps(data)) if response.status_code == 200: print("File created successfully") elif response.status_code == 400: print("File already exists") # Function to create a new directory def create_directory(dir_path): data = {} response = requests.put(firebase_url + dir_path + ".json", data=json.dumps(data)) if response.status_code == 200: print("Directory created successfully") elif response.status_code == 400: print("Directory already exists") # Function to remove a file or directory def remove(path): response = requests.delete(firebase_url + path + ".json") if response.status_code == 200: print("File/directory removed successfully") elif response.status_code == 404:
  • 3. print("File/directory not found") # Function to export the file system structure in XML format def export_xml(): root_data = get_firebase_data(firebase_url + ".json") print("<root>") for key in root_data.keys(): print("<" + key + ">") export_directory(key) print("</" + key + ">") print("</root>") # Function to export a directory and its contents in XML format def export_directory(dir_path): data = get_firebase_data(firebase_url + dir_path + ".json") if isinstance(data, dict): for key in data.keys(): if key == "content": content = data[key] print("<file name='" + dir_path + "'>" + base64.b64encode(content.encode('utf-8')).decode('utf- 8') + "</file>") else: print("<directory name='" + key + "'>") export_directory(dir_path + "/" + key) print("</directory>") # Parse the command-line arguments
  • 4. args = sys.argv if len(args) < 3: print("Usage: python3 edfs.py <command> <path> [content]") exit() command = args[1] x= args[2].split('/') content = x[-1] del x[-1] path='/'.join(x) print(path) # Use the extracted path and file name as needed if command == "-create": if len(args) < 2: print("Usage: python3 edfs.py -create <path> <content>") exit() create_file(path, content) elif command == "-mkdir": create_directory(path) elif command == "-rmdir" or command == "-rm": remove(path) elif command == "-ls": list_directory(path) elif command == "-export":
  • 5. export_xml() else: print("Invalid command: " + command) print("Usage: python3 edfs.py <command> <path> [content]")