Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
c76b2b0d
Commit
c76b2b0d
authored
Aug 26, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new plugin to take current time from the system if this is not defined
parent
c7925d8d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
dream/plugins/GetCurrentTime.py
dream/plugins/GetCurrentTime.py
+30
-0
No files found.
dream/plugins/GetCurrentTime.py
0 → 100644
View file @
c76b2b0d
from
dream.plugins
import
plugin
import
datetime
class
GetCurrentTime
(
plugin
.
InputPreparationPlugin
):
""" Input preparation
if there is no current time defined it gets it from the system
"""
def
preprocess
(
self
,
data
):
currentTime
=
data
[
'general'
].
get
(
'currentDate'
,
None
)
print
'----'
,
currentTime
if
not
currentTime
:
currentTime
=
datetime
.
datetime
.
now
()
year
=
currentTime
.
year
month
=
currentTime
.
month
day
=
currentTime
.
day
minute
=
currentTime
.
minute
hour
=
currentTime
.
hour
minute
=
currentTime
.
minute
second
=
currentTime
.
second
dateFormat
=
data
[
'general'
].
get
(
'dateFormat'
,
'%Y/%m/%d %H:%M'
)
if
dateFormat
==
'%Y/%m/%d %H:%M:%S'
:
currentTimeString
=
str
(
year
)
+
'/'
+
str
(
month
).
zfill
(
2
)
+
'/'
+
str
(
day
).
zfill
(
2
)
+
' '
+
str
(
hour
).
zfill
(
2
)
+
':'
+
str
(
minute
).
zfill
(
2
)
+
':'
+
str
(
second
).
zfill
(
2
)
elif
dateFormat
==
'%Y/%m/%d %H:%M'
:
currentTimeString
=
str
(
year
)
+
'/'
+
str
(
month
).
zfill
(
2
)
+
'/'
+
str
(
day
).
zfill
(
2
)
+
' '
+
str
(
hour
).
zfill
(
2
)
+
':'
+
str
(
minute
).
zfill
(
2
)
elif
dateFormat
==
'%Y/%m/%d'
:
currentTimeString
=
str
(
year
)
+
'/'
+
str
(
month
).
zfill
(
2
)
+
'/'
+
str
(
day
).
zfill
(
2
)
print
currentTimeString
data
[
'general'
][
'currentDate'
]
=
currentTimeString
return
data
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment