Skip to content

Commit

Permalink
WIP #14
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian committed Dec 12, 2024
1 parent 25fd3dc commit c78c095
Show file tree
Hide file tree
Showing 16 changed files with 274 additions and 47 deletions.
6 changes: 4 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ describe the future plans.
Breaking Changes
----------------

* Standardize on **run** instead of **cycle** as the reference used for the
name of an APS operations *run* period.
* Proposal ID is now an integer, was previously text. (ESAF ID is integer,
as before.)
* Standardize on the name **run** instead of **cycle** as the reference used
for the name of an APS operations *run* period.

* Includes EPICS PV: ``record(stringout, "$(P)esaf:run")``

Expand Down
40 changes: 20 additions & 20 deletions apsbss/apsbss.db
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ record(waveform, "$(P)esaf:description") {

record(stringout, "$(P)esaf:endDate")

record(stringout, "$(P)esaf:id")
record(longout, "$(P)esaf:id")

record(waveform, "$(P)esaf:raw") {
field(FTVL, "CHAR")
Expand Down Expand Up @@ -150,7 +150,7 @@ record(bo, "$(P)proposal:mailInFlag") {
field(VAL, 0)
}

record(stringout, "$(P)proposal:id")
record(longout, "$(P)proposal:id")

record(bo, "$(P)proposal:proprietaryFlag") {
field(ZNAM, "OFF")
Expand Down Expand Up @@ -197,7 +197,7 @@ record(waveform, "$(P)proposal:user1:institution") {
field(NELM, 1024)
}

record(stringout, "$(P)proposal:user1:instId")
record(longout, "$(P)proposal:user1:instId")

record(stringout, "$(P)proposal:user1:lastName")

Expand All @@ -207,7 +207,7 @@ record(bo, "$(P)proposal:user1:piFlag") {
field(VAL, 0)
}

record(stringout, "$(P)proposal:user1:userId")
record(longout, "$(P)proposal:user1:userId")

record(stringout, "$(P)proposal:user2:badgeNumber")

Expand All @@ -220,7 +220,7 @@ record(waveform, "$(P)proposal:user2:institution") {
field(NELM, 1024)
}

record(stringout, "$(P)proposal:user2:instId")
record(longout, "$(P)proposal:user2:instId")

record(stringout, "$(P)proposal:user2:lastName")

Expand All @@ -230,7 +230,7 @@ record(bo, "$(P)proposal:user2:piFlag") {
field(VAL, 0)
}

record(stringout, "$(P)proposal:user2:userId")
record(longout, "$(P)proposal:user2:userId")

record(stringout, "$(P)proposal:user3:badgeNumber")

Expand All @@ -243,7 +243,7 @@ record(waveform, "$(P)proposal:user3:institution") {
field(NELM, 1024)
}

record(stringout, "$(P)proposal:user3:instId")
record(longout, "$(P)proposal:user3:instId")

record(stringout, "$(P)proposal:user3:lastName")

Expand All @@ -253,7 +253,7 @@ record(bo, "$(P)proposal:user3:piFlag") {
field(VAL, 0)
}

record(stringout, "$(P)proposal:user3:userId")
record(longout, "$(P)proposal:user3:userId")

record(stringout, "$(P)proposal:user4:badgeNumber")

Expand All @@ -266,7 +266,7 @@ record(waveform, "$(P)proposal:user4:institution") {
field(NELM, 1024)
}

record(stringout, "$(P)proposal:user4:instId")
record(longout, "$(P)proposal:user4:instId")

record(stringout, "$(P)proposal:user4:lastName")

Expand All @@ -276,7 +276,7 @@ record(bo, "$(P)proposal:user4:piFlag") {
field(VAL, 0)
}

record(stringout, "$(P)proposal:user4:userId")
record(longout, "$(P)proposal:user4:userId")

record(stringout, "$(P)proposal:user5:badgeNumber")

Expand All @@ -289,7 +289,7 @@ record(waveform, "$(P)proposal:user5:institution") {
field(NELM, 1024)
}

record(stringout, "$(P)proposal:user5:instId")
record(longout, "$(P)proposal:user5:instId")

record(stringout, "$(P)proposal:user5:lastName")

Expand All @@ -299,7 +299,7 @@ record(bo, "$(P)proposal:user5:piFlag") {
field(VAL, 0)
}

record(stringout, "$(P)proposal:user5:userId")
record(longout, "$(P)proposal:user5:userId")

record(stringout, "$(P)proposal:user6:badgeNumber")

Expand All @@ -312,7 +312,7 @@ record(waveform, "$(P)proposal:user6:institution") {
field(NELM, 1024)
}

record(stringout, "$(P)proposal:user6:instId")
record(longout, "$(P)proposal:user6:instId")

record(stringout, "$(P)proposal:user6:lastName")

Expand All @@ -322,7 +322,7 @@ record(bo, "$(P)proposal:user6:piFlag") {
field(VAL, 0)
}

record(stringout, "$(P)proposal:user6:userId")
record(longout, "$(P)proposal:user6:userId")

record(stringout, "$(P)proposal:user7:badgeNumber")

Expand All @@ -335,7 +335,7 @@ record(waveform, "$(P)proposal:user7:institution") {
field(NELM, 1024)
}

record(stringout, "$(P)proposal:user7:instId")
record(longout, "$(P)proposal:user7:instId")

record(stringout, "$(P)proposal:user7:lastName")

Expand All @@ -345,7 +345,7 @@ record(bo, "$(P)proposal:user7:piFlag") {
field(VAL, 0)
}

record(stringout, "$(P)proposal:user7:userId")
record(longout, "$(P)proposal:user7:userId")

record(stringout, "$(P)proposal:user8:badgeNumber")

Expand All @@ -358,7 +358,7 @@ record(waveform, "$(P)proposal:user8:institution") {
field(NELM, 1024)
}

record(stringout, "$(P)proposal:user8:instId")
record(longout, "$(P)proposal:user8:instId")

record(stringout, "$(P)proposal:user8:lastName")

Expand All @@ -368,7 +368,7 @@ record(bo, "$(P)proposal:user8:piFlag") {
field(VAL, 0)
}

record(stringout, "$(P)proposal:user8:userId")
record(longout, "$(P)proposal:user8:userId")

record(stringout, "$(P)proposal:user9:badgeNumber")

Expand All @@ -381,7 +381,7 @@ record(waveform, "$(P)proposal:user9:institution") {
field(NELM, 1024)
}

record(stringout, "$(P)proposal:user9:instId")
record(longout, "$(P)proposal:user9:instId")

record(stringout, "$(P)proposal:user9:lastName")

Expand All @@ -391,4 +391,4 @@ record(bo, "$(P)proposal:user9:piFlag") {
field(VAL, 0)
}

record(stringout, "$(P)proposal:user9:userId")
record(longout, "$(P)proposal:user9:userId")
26 changes: 13 additions & 13 deletions apsbss/apsbss.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
CONNECT_TIMEOUT = 3
logger = logging.getLogger(__name__)
parser = None
server = Server()
server = Server(creds_file=os.environ.get("APSBSS_CREDS_FILE"))


class EpicsNotConnected(Exception):
Expand Down Expand Up @@ -175,25 +175,25 @@ def epicsUpdate(prefix):

bss.status_msg.put("set Proposal PVs ...")
bss.proposal.end_date.put(str(proposal.endTime))
bss.proposal.mail_in_flag.put(proposal._raw.get("mailInFlag") in ("Y", "y"))
bss.proposal.proprietary_flag.put(proposal._raw.get("proprietaryFlag") in ("Y", "y"))
bss.proposal.mail_in_flag.put(proposal.mail_in)
bss.proposal.proprietary_flag.put(proposal.proprietary)
bss.proposal.raw.put(yaml.dump(proposal))
bss.proposal.start_date.put(str(proposal.startTime))
bss.proposal.submitted_date.put(proposal._raw["submittedDate"])
bss.proposal.submitted_date.put(proposal.submittedDate)
bss.proposal.title.put(proposal.title)

bss.proposal.user_last_names.put(",".join([user.lastName for user in proposal._users]))
bss.proposal.user_badges.put(",".join([user.badge for user in proposal._users]))
bss.proposal.user_last_names.put(",".join(proposal.lastNames))
bss.proposal.user_badges.put(",".join(proposal.badges))
bss.proposal.number_users_in_pvs.put(0)
for i, user in enumerate(proposal._users):
obj = getattr(bss.proposal, f"user{i+1}")
obj.badge_number.put(user.badge)
obj.email.put(user.email)
obj.first_name.put(user.firstName)
obj.last_name.put(user.lastName)
obj.institution.put(user._raw["institution"])
obj.institution_id.put(str(user._raw["instId"]))
obj.user_id.put(str(user._raw["id"]))
obj.institution.put(user.institution)
obj.institution_id.put(user.institution_id)
obj.user_id.put(user.user_id)
obj.pi_flag.put(user.is_pi)
bss.proposal.number_users_in_pvs.put(i + 1)
if i == 8:
Expand Down Expand Up @@ -311,7 +311,7 @@ def get_options():
p_sub.add_argument("beamlineName", type=str, help="Beamline name")

p_sub = subcommand.add_parser("proposal", help="print specific proposal")
p_sub.add_argument("proposalId", type=str, help="proposal ID number")
p_sub.add_argument("proposalId", type=int, help="proposal ID number")
p_sub.add_argument("run", type=str, help="APS run name")
p_sub.add_argument("beamlineName", type=str, help="Beamline name")

Expand Down Expand Up @@ -346,7 +346,7 @@ def cmd_esaf(args):
esaf = server.esaf(args.esafId)
print(yaml.dump(esaf))
except Exception as reason:
print(f"DM reported: {reason}")
print(f"Exception: {reason}")


def cmd_list(args):
Expand Down Expand Up @@ -385,9 +385,9 @@ def cmd_proposal(args):
"""
try:
proposal = server.proposal(args.proposalId, args.beamlineName, args.run)
print(yaml.dump(proposal))
print(yaml.dump(proposal.to_dict()))
except Exception as reason:
print(f"DM reported: {reason}")
print(f"Exception: {reason}")


def cmd_report(args):
Expand Down
Loading

0 comments on commit c78c095

Please sign in to comment.