Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
KalturaSync
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
icommonsCRC
KalturaSync
Commits
625a2f6e
Unverified
Commit
625a2f6e
authored
2 years ago
by
icommonsCRC
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Create upload.py
parent
20d41408
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
upload.py
+65
-0
65 additions, 0 deletions
upload.py
with
65 additions
and
0 deletions
upload.py
0 → 100644
+
65
−
0
View file @
625a2f6e
# Created by Kyle Goetke
import
pysftp
import
shutil
import
os
import
sys
def
files_in_directory
(
PATH
):
onlyfiles
=
[
f
for
f
in
os
.
listdir
(
PATH
)
if
os
.
path
.
isfile
(
os
.
path
.
join
(
PATH
,
f
))]
return
(
onlyfiles
)
def
main
():
# define constant variables
HOST
=
""
# sftp host
USERNAME
=
""
# sftp username
PASSWORD
=
""
# sftp password
PATH
=
""
# path to OBS save location for recordings
CNOPTS
=
pysftp
.
CnOpts
()
CNOPTS
.
hostkeys
=
None
USER_ID
=
""
# add your abc123
file_list
=
files_in_directory
(
PATH
)
for
file
in
file_list
:
print
(
f
"
[
{
file_list
.
index
(
file
)
}
]
{
file
}
"
)
choice
=
int
(
input
(
"
\n
Which file would you like to upload?
\n
#
"
))
if
str
(
choice
)
==
"
-1
"
:
exit
filename
=
file_list
[
choice
]
name
=
filename
description
=
filename
[:
-
4
]
# full filename minus the file extension
new_xml_file
=
"
XML/
"
+
description
+
"
.xml
"
shutil
.
copyfile
(
"
XML/template.xml
"
,
new_xml_file
)
print
(
"
\n
> XML TEMPLATE COPIED
"
)
with
open
(
new_xml_file
,
"
r
"
)
as
file
:
data
=
file
.
readlines
()
data
[
6
]
=
f
"
<userId>
{
USER_ID
}
</userId>
\n
"
data
[
7
]
=
f
"
<name>
{
name
}
</name>
\n
"
data
[
8
]
=
f
"
<description>
{
description
}
</description>
\n
"
data
[
19
]
=
f
'
<dropFolderFileContentResource filePath=
"
{
filename
}
"
>
\n
'
with
open
(
new_xml_file
,
"
w
"
)
as
file
:
file
.
writelines
(
data
)
print
(
"
> XML UPDATED
"
)
with
pysftp
.
Connection
(
HOST
,
username
=
USERNAME
,
password
=
PASSWORD
,
cnopts
=
CNOPTS
)
as
SFTP
:
print
(
"
\n
SFTP:
"
,
SFTP
.
listdir
())
SFTP
.
put
(
f
"
{
PATH
}{
filename
}
"
)
SFTP
.
put
(
new_xml_file
)
print
(
"
SFTP:
"
,
SFTP
.
listdir
())
print
(
"
> FILES PUSHED
"
)
print
(
"
\n
ALL FILES PROCESSED
"
)
if
__name__
==
'
__main__
'
:
try
:
main
()
except
KeyboardInterrupt
:
try
:
sys
.
exit
(
0
)
except
SystemExit
:
os
.
_exit
(
0
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment